GRASS GIS 8 Programmer's Manual  8.5.0dev(2025)-eb16a2cfc9
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parser_md.c
Go to the documentation of this file.
1 /*!
2  \file lib/gis/parser_md.c
3 
4  \brief GIS Library - Argument parsing functions (Markdown output)
5 
6  (C) 2012-2025 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Martin Landa
12  \author Vaclav Petras
13  */
14 #include <stdio.h>
15 #include <string.h>
16 
17 #include <grass/gis.h>
18 #include <grass/glocale.h>
19 
20 #include "parser_local_proto.h"
21 
22 /*!
23  \brief Print module usage description in Markdown format.
24  */
26 {
27  if (!st->pgm_name)
28  st->pgm_name = G_program_name();
29  if (!st->pgm_name)
30  st->pgm_name = "??";
31 
32  /* print metadata used by man/build*.py */
33  fprintf(stdout, "---\n");
34  fprintf(stdout, "name: %s\n", st->pgm_name);
35  fprintf(stdout, "description: ");
36  if (st->module_info.label)
37  fprintf(stdout, "%s", st->module_info.label);
38  if (st->module_info.label && st->module_info.description)
39  fprintf(stdout, " ");
40  if (st->module_info.description)
41  fprintf(stdout, "%s", st->module_info.description);
42  fprintf(stdout, "\n");
43  fprintf(stdout, "keywords: [ ");
44  G__print_keywords(stdout, NULL, FALSE);
45  fprintf(stdout, " ]");
46  fprintf(stdout, "\n---\n\n");
47 
48  /* main header */
49  fprintf(stdout, "# %s\n\n", st->pgm_name);
50 
51  /* header */
52  if (st->module_info.label)
53  fprintf(stdout, "%s\n", st->module_info.label);
54 
55  if (st->module_info.description) {
56  if (st->module_info.label)
57  fprintf(stdout, "\n");
58  fprintf(stdout, "%s\n", st->module_info.description);
59  }
60 
61  const char *tab_indent = " ";
62 
63  /* short version */
64  fprintf(stdout, "\n=== \"Command line\"\n\n");
65  G__md_print_cli_short_version(stdout, tab_indent);
66  fprintf(stdout, "\n=== \"Python (grass.script)\"\n\n");
67  G__md_print_python_short_version(stdout, tab_indent);
68 
69  fprintf(stdout, "\n## %s\n", _("Parameters"));
70 
71  /* long version */
72  fprintf(stdout, "\n=== \"Command line\"\n\n");
73  G__md_print_cli_long_version(stdout, tab_indent);
74  fprintf(stdout, "\n=== \"Python (grass.script)\"\n\n");
75  G__md_print_python_long_version(stdout, tab_indent);
76 }
#define NULL
Definition: ccmath.h:32
const char * G_program_name(void)
Return module name.
Definition: progrm_nme.c:28
#define FALSE
Definition: gis.h:82
#define _(str)
Definition: glocale.h:10
void G__print_keywords(FILE *fd, void(*format)(FILE *, const char *), int newline)
Print list of keywords (internal use only)
Definition: parser.c:930
struct state * st
Definition: parser.c:104
void G__usage_markdown(void)
Print module usage description in Markdown format.
Definition: parser_md.c:25
void G__md_print_cli_long_version(FILE *file, const char *indent)
void G__md_print_cli_short_version(FILE *file, const char *indent)
void G__md_print_python_long_version(FILE *file, const char *indent)
void G__md_print_python_short_version(FILE *file, const char *indent)