After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752126 - Add support for inline program documentation
Add support for inline program documentation
Status: RESOLVED FIXED
Product: gtk-doc
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: 1.26
Assigned To: gtk-doc maintainers
gtk-doc maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-08 13:50 UTC by Thomas Wood
Modified: 2016-05-12 06:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add support for inline program documentation (10.80 KB, patch)
2015-07-08 13:50 UTC, Thomas Wood
needs-work Details | Review
Add support for inline program documentation (7.38 KB, patch)
2015-07-09 17:31 UTC, Thomas Wood
none Details | Review
mkdb: add support for exit status in program documentation (1.90 KB, patch)
2015-07-14 10:49 UTC, Thomas Wood
none Details | Review
mkdb: add support for the options section (3.02 KB, patch)
2015-07-14 10:59 UTC, Thomas Wood
none Details | Review
mkdb: parse command synopsis for parameters (2.31 KB, patch)
2015-07-14 11:04 UTC, Thomas Wood
none Details | Review
Add support for inline program documentation (10.31 KB, patch)
2015-07-16 15:22 UTC, Thomas Wood
none Details | Review
Add support for inline program documentation (17.78 KB, patch)
2015-10-20 15:34 UTC, Thomas Wood
committed Details | Review
Add support for inline program documentation (17.79 KB, patch)
2016-03-23 21:06 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
committed Details | Review
Documentation (2.88 KB, patch)
2016-05-04 14:56 UTC, Marius Vlad
needs-work Details | Review
Documentation (revised) (3.22 KB, patch)
2016-05-05 15:56 UTC, Marius Vlad
committed Details | Review
help/manual/C: Added documentation for inline program documentation. (3.28 KB, patch)
2016-05-12 06:16 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
committed Details | Review

Description Thomas Wood 2015-07-08 13:50:01 UTC
Create program documentation from documentation comments in source files.
Comment 1 Thomas Wood 2015-07-08 13:50:07 UTC
Created attachment 307074 [details] [review]
Add support for inline program documentation

Create program documentation from documentation comments in source
files.
Comment 2 Thomas Wood 2015-07-08 13:59:38 UTC
Review of attachment 307074 [details] [review]:

This patch supports various sections, including cmdsynopsis which is specific to program documentation. However, it is missing support for a separate options section and the new feature needs adding to the gtk-doc documentation.
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2015-07-08 14:30:17 UTC
Review of attachment 307074 [details] [review]:

Can you attach a sample doc comment?

::: gtkdoc-scan.in
@@ +271,3 @@
+        if (m/\s\*\sPROGRAM\s*(.*)/) {
+            @TRACE@("Found PROGRAM comment in $input_file");
+    if ($input_file =~ m/^.*[\/\\](.*)\.c+$/) {

Hmm, can we also just create a <SECTION> entry here?
Comment 4 Thomas Wood 2015-07-08 14:46:34 UTC
(In reply to Stefan Sauer (gstreamer, gtkdoc dev) from comment #3)
> Review of attachment 307074 [details] [review] [review]:

> ::: gtkdoc-scan.in
> @@ +271,3 @@
> +        if (m/\s\*\sPROGRAM\s*(.*)/) {
> +            @TRACE@("Found PROGRAM comment in $input_file");
> +    if ($input_file =~ m/^.*[\/\\](.*)\.c+$/) {
> 
> Hmm, can we also just create a <SECTION> entry here?

A <SECTION> entry require at least one symbol before output is created, which wouldn't be the case for a program. The <PROGRAM> section also identifies the section as a program and therefore OutputProgramDBFile() is used, which includes the program specific sections.
Comment 5 Thomas Wood 2015-07-09 17:31:19 UTC
Created attachment 307164 [details] [review]
Add support for inline program documentation

Create program documentation from documentation comments in source
files.
Comment 6 Thomas Wood 2015-07-09 17:32:38 UTC
Review of attachment 307164 [details] [review]:

This version skips the sections file altogether and outputs the program documentation directly from gtkdoc-mkdb.
Comment 7 Thomas Wood 2015-07-10 14:49:21 UTC
Sample documentation comment:

 /**
  * PROGRAM:program-name
  * @short_description: short description of program
  * @synposis: program-name [OPTIONS]
  *
  * Long description of program.
  */
Comment 8 Stefan Sauer (gstreamer, gtkdoc dev) 2015-07-10 19:56:30 UTC
Two ideas:

/**
  * PROGRAM:program-name
  * @short_description: short description of program
  * @synposis: program-name [OPTIONS]
  * @opt.help: display short help
  * @opt.version: show program version
  * @env.TOOL: if set do ... 
  *
  * Long description of program.
  *
  * Returns: 0 for success and -1 in case of error
  */

If we don't want to do the special prefixed vars like "@opt." and "@env." another idea would be:

/**
  * PROGRAM:program-name
  * @short_description: short description of program
  * @synposis: program-name [OPTIONS]
  * @opt.help: display short help
  * @opt.version: show program version
  * @env.TOOL: if set do ... 
  *
  * Long description of program.
  *
  * Returns: 0 for success and -1 in case of error
  */
/**
  * program-name:options
  * @help: display short help
  * @version: show program version
  *
  * Free form option docs.
  */
/**
  * program-name:environment
  * @TOOL: if set do ... 
  *
  * Free form env docs.
  */

Still weird, right? Another option would be markdown for the whole block.
Comment 9 Thomas Wood 2015-07-14 10:49:49 UTC
Created attachment 307401 [details] [review]
mkdb: add support for exit status in program documentation

Add exit status section by using the "Returns:" documentation.
Comment 10 Thomas Wood 2015-07-14 10:59:03 UTC
Created attachment 307402 [details] [review]
mkdb: add support for the options section

Options can be listed as parameters in the PROGRAM section by prefixing the
option with "opt." Parameters in square brackets are converted to
replaceable entries.

This implementation doesn't automatically add a '-' or '--' prefix to options,
so these need to be included in the option name. The options also cannot
contain spaces, so any arguments to options need to include an equals symbol.
There is also no support for more than one option with the same description
(e.g. "-h, --help").


/**
  * PROGRAM:program-name
  * @synopsis: program-name [OPTIONS...]
  * @opt.--file=[FILENAME]: specify a file
  * @opt.--help: display short help
  */
Comment 11 Thomas Wood 2015-07-14 11:04:22 UTC
Created attachment 307403 [details] [review]
mkdb: parse command synopsis for parameters

Create command and arg tags for the cmdsynopsis section. The first item
is the command name and any subsequent items are parameters. If a
parameter is enclosed in square brackets it is marked as optional and
curly brackets indicate the parameter is required. Parameters ending in
"..." are repeatable and if the parameter is upper case, it is
replaceable.

/**
  * PROGRAM:program-name
  * @synopsis: program-name [OPTIONS...] --module=MODULE_NAME {FILE}
  */
Comment 12 Thomas Wood 2015-07-16 15:22:10 UTC
Created attachment 307568 [details] [review]
Add support for inline program documentation

This patch combines the previous patches and makes the following changes:

 * Use *italic* markdown formatting for replaceable elements. This matches the
   man page convention of using italics to indicate replaceable arguments.
 * Add default synopsis section using the program name.
 * Make the Options section optional.
 * Split options based on commas to support multiple options with a single
   description (e.g. "-h, --help: display help text").
 * Don't require "opt." prefix for command options, instead require command
   line options to start with '-'.
 * Allow spaces in parameter names to allow "--arg value" instead of
   "--arg=value".
 * Parse markdown in the Exit Status section.
 * Remove @title override support as the title should always be the program
   name.
Comment 13 Thomas Wood 2015-10-20 15:34:07 UTC
Created attachment 313759 [details] [review]
Add support for inline program documentation

This version of the patch adds a test for program documentation and also fixes
parameter matching with spaces by using non-greedy matching.
Comment 14 Stefan Sauer (gstreamer, gtkdoc dev) 2016-03-23 21:06:02 UTC
The following fix has been pushed:
a9864c4 Add support for inline program documentation
Comment 15 Stefan Sauer (gstreamer, gtkdoc dev) 2016-03-23 21:06:11 UTC
Created attachment 324626 [details] [review]
Add support for inline program documentation

Create program documentation from documentation comments in source
files.
Comment 16 Stefan Sauer (gstreamer, gtkdoc dev) 2016-03-23 21:07:14 UTC
Sorry for the long delay in reviews. Could you also please send a patch for the docs as a followup.
Comment 17 Marius Vlad 2016-03-24 15:19:39 UTC
Hello,

Thanks for the update. Sure do. Should I use the ml for that?
Comment 18 Stefan Sauer (gstreamer, gtkdoc dev) 2016-03-24 18:05:05 UTC
Marius, the docs are in docbook here:
https://git.gnome.org/browse/gtk-doc/tree/help/manual/C/index.docbook

You could add a section after this one:
https://developer.gnome.org/gtk-doc-manual/unstable/documenting_symbols.html.en
Comment 19 Stefan Sauer (gstreamer, gtkdoc dev) 2016-04-19 18:41:58 UTC
Ping, I would need this for the next release.
Comment 20 Marius Vlad 2016-04-25 16:16:11 UTC
Haven't forgotten, just a little caught up w/ other stuff. Will try to do it this week.
Comment 21 Marius Vlad 2016-05-04 14:56:36 UTC
Created attachment 327300 [details] [review]
Documentation

Added a patch for documentation. First attempt, let me know if this complies.
Comment 22 Stefan Sauer (gstreamer, gtkdoc dev) 2016-05-05 02:05:17 UTC
Review of attachment 327300 [details] [review]:

Thanks

::: help/manual/C/index.docbook
@@ +1412,3 @@
     </sect1>
 
+	<sect1 id="documenting_inline_program">

Please fix the indentation.

@@ +1415,3 @@
+	<title>Inline program documentation</title>
+		<para>
+			You can document programs using inline documentation.

You can document programs and their commandline interface using inline documentation.
Comment 23 Marius Vlad 2016-05-05 15:56:26 UTC
Created attachment 327356 [details] [review]
Documentation (revised)

Uploaded a revised version.
Comment 24 Stefan Sauer (gstreamer, gtkdoc dev) 2016-05-12 06:16:49 UTC
The following fix has been pushed:
dc31758 help/manual/C: Added documentation for inline program documentation.
Comment 25 Stefan Sauer (gstreamer, gtkdoc dev) 2016-05-12 06:16:57 UTC
Created attachment 327675 [details] [review]
help/manual/C: Added documentation for inline program documentation.

v2: Fixed indentation and description (Stefan Sauer)

Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>