aboutsummaryrefslogtreecommitdiff
path: root/src/compile
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-24 01:12:41 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-24 01:12:41 -0500
commit8de3edded640dfb4dc27fd5afae77faa2bf4acd5 (patch)
tree9e467ac3bcfcee8e7393a644d6f39028d566081a /src/compile
parent83a2bff4bb04b0189d17419baf8ca520992d5033 (diff)
Add MANPAGE metadata for overriding whole file
Diffstat (limited to 'src/compile')
-rw-r--r--src/compile/cli.c11
-rw-r--r--src/compile/cli.h2
2 files changed, 10 insertions, 3 deletions
diff --git a/src/compile/cli.c b/src/compile/cli.c
index b92a5784..7cd3cc7c 100644
--- a/src/compile/cli.c
+++ b/src/compile/cli.c
@@ -187,14 +187,21 @@ Text_t compile_cli_arg_call(env_t *env, ast_t *ast, Text_t fn_name, type_t *fn_t
}
public
-Text_t compile_manpage(Text_t program, OptionalText_t synopsis, OptionalText_t description, arg_t *args) {
+Text_t compile_manpage(Text_t program, ast_t *ast, arg_t *args) {
+ OptionalText_t user_manpage = ast_metadata(ast, "MANPAGE");
+ if (user_manpage.tag != TEXT_NONE) {
+ return user_manpage;
+ }
+
+ OptionalText_t synopsys = ast_metadata(ast, "MANPAGE_SYNOPSYS");
+ OptionalText_t description = ast_metadata(ast, "MANPAGE_DESCRIPTION");
Text_t date = Text(""); // TODO: use date
Text_t man = Texts(".\\\" Automatically generated by Tomo\n"
".TH \"",
Text$upper(program, Text("C")), "\" \"1\" \"", date,
"\" \"\" \"\"\n"
".SH NAME\n",
- program, " \\- ", synopsis.tag == TEXT_NONE ? Text("a Tomo program") : synopsis, "\n");
+ program, " \\- ", synopsys.tag == TEXT_NONE ? Text("a Tomo program") : synopsys, "\n");
if (description.tag != TEXT_NONE) {
man = Texts(man, ".SH DESCRIPTION\n", description, "\n");
diff --git a/src/compile/cli.h b/src/compile/cli.h
index fbb7347b..907554a6 100644
--- a/src/compile/cli.h
+++ b/src/compile/cli.h
@@ -8,4 +8,4 @@
#include "../types.h"
Text_t compile_cli_arg_call(env_t *env, ast_t *ast, Text_t fn_name, type_t *fn_type, const char *version);
-Text_t compile_manpage(Text_t program, OptionalText_t synopsis, OptionalText_t description, arg_t *args);
+Text_t compile_manpage(Text_t program, ast_t *ast, arg_t *args);