about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--.builds/openbsd.yml23
-rw-r--r--Makefile.am2
-rw-r--r--RELEASE_GUIDE.md4
-rw-r--r--docs/profanity.11
-rw-r--r--src/command/cmd_defs.c77
-rw-r--r--src/command/cmd_defs.h1
-rw-r--r--src/main.c11
7 files changed, 107 insertions, 12 deletions
diff --git a/.builds/openbsd.yml b/.builds/openbsd.yml
index 21cc104e..71c070df 100644
--- a/.builds/openbsd.yml
+++ b/.builds/openbsd.yml
@@ -1,4 +1,4 @@
-image: openbsd/6.7
+image: openbsd/6.8
 
 packages:
   - cmake
@@ -8,10 +8,9 @@ packages:
   - automake-1.16.2
   - pkgconf
   - readline
-  - python-3.8.2
-  - autoconf-2.69p2
+  - python-3.8.6p0
+  - autoconf-2.69p3
   - autoconf-archive
-  - libmesode
   - curl
   - gpgme
   - glib2
@@ -24,6 +23,7 @@ packages:
   - sqlite3
 
 sources:
+  - https://github.com/profanity-im/libmesode.git#0.10.1
   - https://github.com/profanity-im/profanity
 
 environment:
@@ -31,11 +31,18 @@ environment:
 
 tasks:
   - symlink: |
-      doas ln -sf /usr/local/bin/python3.7 /usr/local/bin/python
-      doas ln -sf /usr/local/bin/python3.7-config /usr/local/bin/python-config
-      doas ln -sf /usr/local/bin/pydoc3.7  /usr/local/bin/pydoc
+      doas ln -sf /usr/local/bin/python3 /usr/local/bin/python
+      doas ln -sf /usr/local/bin/python3-config /usr/local/bin/python-config
+      doas ln -sf /usr/local/bin/pydoc3  /usr/local/bin/pydoc
   - build: |
       export AUTOCONF_VERSION=2.69
       export AUTOMAKE_VERSION=1.16
-      cd profanity
+
+      cd ~/libmesode
+      ./bootstrap.sh
+      ./configure
+      make
+      doas make install
+
+      cd ~/profanity
       ./ci-build.sh
diff --git a/Makefile.am b/Makefile.am
index c554f11c..d40494d1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -220,7 +220,7 @@ icons_sources = $(top_srcdir)/icons/*
 
 script_sources = bootstrap.sh
 
-man_sources = docs/profanity.1
+man_sources = docs/profanity*.1
 
 if BUILD_PGP
 core_sources += $(pgp_sources)
diff --git a/RELEASE_GUIDE.md b/RELEASE_GUIDE.md
index 2871d0f2..719a5969 100644
--- a/RELEASE_GUIDE.md
+++ b/RELEASE_GUIDE.md
@@ -15,6 +15,10 @@ Usually release candidates are tagged 0.6.0.rc1, 0.6.0.rc2 and tested for a week
 * Generate HTML docs (the docgen argument only works when package status is development)
     `./profanity docgen`
 
+* Generate manpages for profanity commands (the mangen argument only works when package status is development)
+    `./profanity mangen`
+  These files should be added to the docs subfolder and added to git whenever a command changes.
+
 * Determine if libprofanitys version needs to be [increased](https://github.com/profanity-im/profanity/issues/973)
 * Update plugin API docs (./apidocs/c and ./apidocs/python) need to run the `gen.sh` and commit the results to the website git repo
 * Update CHANGELOG
diff --git a/docs/profanity.1 b/docs/profanity.1
index 291d8335..26a77a1d 100644
--- a/docs/profanity.1
+++ b/docs/profanity.1
@@ -46,6 +46,7 @@ The user guide can be found at <https://profanity-im.github.io/userguide.html>.
 .B Profanity
 itself has a lot of built\-in help. Check the /help command for more information.
 Type "/help help" for information on how to use help itself.
+Profanity ships with one man page for each built-in command. For /account there is man profanity-account.
 .SH CONFIGURATION
 Configuration for
 .B Profanity
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 4a78ba70..5058a573 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -2839,3 +2839,80 @@ command_docgen(void)
     printf("\nProcessed %d commands.\n\n", g_list_length(cmds));
     g_list_free(cmds);
 }
+
+void
+command_mangen(void)
+{
+    GList* cmds = NULL;
+
+    for (unsigned int i = 0; i < ARRAY_SIZE(command_defs); i++) {
+        Command* pcmd = command_defs + i;
+        cmds = g_list_insert_sorted(cmds, pcmd, (GCompareFunc)_cmp_command);
+    }
+
+    mkdir_recursive("docs");
+
+    char* header = NULL;
+    GDateTime *now = g_date_time_new_now_local();
+    gchar *date = g_date_time_format(now, "%F");
+    if (asprintf(&header, ".TH man 1 \"%s\" \""PACKAGE_VERSION"\" \"Profanity XMPP client\"\n", date) == -1) {
+        // TODO: error
+        return;
+    }
+    g_date_time_unref(now);
+    g_free(date);
+
+    GList* curr = cmds;
+    while (curr) {
+        Command* pcmd = curr->data;
+
+        char* filename = NULL;
+        if (asprintf(&filename, "docs/profanity-%s.1", &pcmd->cmd[1]) == -1) {
+            // TODO: error
+            return;
+        }
+        FILE* manpage = fopen(filename, "w");
+        free(filename);
+
+        fprintf(manpage, "%s\n", header);
+        fputs(".SH NAME\n", manpage);
+        fprintf(manpage, "%s\n", pcmd->cmd);
+
+        fputs("\n.SH DESCRIPTION\n", manpage);
+        fprintf(manpage, "%s\n", pcmd->help.desc);
+
+        fputs("\n.SH SYNOPSIS\n", manpage);
+        int i = 0;
+        while (pcmd->help.synopsis[i]) {
+            fprintf(manpage, "%s\n", pcmd->help.synopsis[i]);
+            fputs("\n.LP\n", manpage);
+            i++;
+        }
+
+        if (pcmd->help.args[0][0] != NULL) {
+            fputs("\n.SH ARGUMENTS\n", manpage);
+            for (i = 0; pcmd->help.args[i][0] != NULL; i++) {
+                fprintf(manpage, ".PP\n\\fB%s\\fR\n", pcmd->help.args[i][0]);
+                fprintf(manpage, ".RS 4\n%s\n.RE\n", pcmd->help.args[i][1]);
+            }
+        }
+
+        if (pcmd->help.examples[0] != NULL) {
+            fputs("\n.SH EXAMPLES\n", manpage);
+            int i = 0;
+            while (pcmd->help.examples[i]) {
+                fprintf(manpage, "%s\n", pcmd->help.examples[i]);
+                fputs("\n.LP\n", manpage);
+                i++;
+            }
+        }
+
+        fclose(manpage);
+        curr = g_list_next(curr);
+    }
+
+    printf("\nProcessed %d commands.\n\n", g_list_length(cmds));
+
+    free(header);
+    g_list_free(cmds);
+}
diff --git a/src/command/cmd_defs.h b/src/command/cmd_defs.h
index 32167c6d..c288d8b0 100644
--- a/src/command/cmd_defs.h
+++ b/src/command/cmd_defs.h
@@ -50,6 +50,7 @@ GList* cmd_get_ordered(const char* const tag);
 gboolean cmd_valid_tag(const char* const str);
 
 void command_docgen(void);
+void command_mangen(void);
 
 GList* cmd_search_index_all(char* term);
 GList* cmd_search_index_any(char* term);
diff --git a/src/main.c b/src/main.c
index b7e2f6dd..d2027590 100644
--- a/src/main.c
+++ b/src/main.c
@@ -69,9 +69,14 @@ static char* theme_name = NULL;
 int
 main(int argc, char** argv)
 {
-    if (argc == 2 && g_strcmp0(argv[1], "docgen") == 0 && g_strcmp0(PACKAGE_STATUS, "development") == 0) {
-        command_docgen();
-        return 0;
+    if (argc == 2  && g_strcmp0(PACKAGE_STATUS, "development") == 0) {
+        if (g_strcmp0(argv[1], "docgen") == 0) {
+            command_docgen();
+            return 0;
+        } else if (g_strcmp0(argv[1], "mangen") == 0) {
+            command_mangen();
+            return 0;
+        }
     }
 
     static GOptionEntry entries[] = {