GRASS GIS 8 Programmer's Manual  8.5.0dev(2025)-a277d8547c
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: %s\n", st->module_info.description);
36  fprintf(stdout, "keywords: [ ");
37  G__print_keywords(stdout, NULL, FALSE);
38  fprintf(stdout, " ]");
39  fprintf(stdout, "\n---\n\n");
40 
41  /* main header */
42  fprintf(stdout, "# %s\n\n", st->pgm_name);
43 
44  /* header */
45  if (st->module_info.label)
46  fprintf(stdout, "%s\n", st->module_info.label);
47 
48  if (st->module_info.description) {
49  if (st->module_info.label)
50  fprintf(stdout, "\n");
51  fprintf(stdout, "%s\n", st->module_info.description);
52  }
53 
54  const char *tab_indent = " ";
55 
56  /* short version */
57  fprintf(stdout, "\n=== \"Command line\"\n\n");
58  G__md_print_cli_short_version(stdout, tab_indent);
59  fprintf(stdout, "\n=== \"Python (grass.script)\"\n\n");
60  G__md_print_python_short_version(stdout, tab_indent);
61 
62  fprintf(stdout, "\n## %s\n", _("Parameters"));
63 
64  /* long version */
65  fprintf(stdout, "\n=== \"Command line\"\n\n");
66  G__md_print_cli_long_version(stdout, tab_indent);
67  fprintf(stdout, "\n=== \"Python (grass.script)\"\n\n");
68  G__md_print_python_long_version(stdout, tab_indent);
69 }
#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)