Skip to content

Commit 08286fb

Browse files
authored
docs: Use YAML list for keywords in front matter (#5320)
To use the keywords directly in MkDocs, keywords property needs to be proper YAML list, not a plain comma-separated list as a string. The keywords are now generated like that, and the custom keyword parsing now accepts both version (with and without []). This does not include any keywords entered manually to Markdown because there are none in this repo, but they are in grass-addons repo which will break the MkDocs reading of the tags from the keywords property (for r.pi, r.green). Addons are addressed in OSGeo/grass-addons#1357. This includes cleanup of keywords tool metadata syntax which is supposed to use multiple keyword keys now rather than keywords (for a single keyword). For the tags page generated by MkDocs, this adds an exclude of keyword 'unit test' which does not need to appear in the documentation. This covers only the YAML changes for keywords. The MkDocs change for tags to keywords is in #5318.
1 parent 0c0fb75 commit 08286fb

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

gui/wxpython/timeline/g.gui.timeline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# % keyword: general
2525
# % keyword: GUI
2626
# % keyword: temporal
27-
# % keywords: plot
27+
# % keyword: plot
2828
# %end
2929
# %option G_OPT_STDS_INPUTS
3030
# % required: no

gui/wxpython/tplot/g.gui.tplot.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
# %module
2424
# % description: Plots the values of temporal datasets.
25-
# % keywords: general
26-
# % keywords: GUI
27-
# % keywords: temporal
28-
# % keywords: plot
25+
# % keyword: general
26+
# % keyword: GUI
27+
# % keyword: temporal
28+
# % keyword: plot
2929
# %end
3030

3131
# %flag

lib/gis/parser_md.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ void G__usage_markdown(void)
4949
fprintf(stdout, "---\n");
5050
fprintf(stdout, "name: %s\n", st->pgm_name);
5151
fprintf(stdout, "description: %s\n", st->module_info.description);
52-
fprintf(stdout, "keywords: ");
52+
fprintf(stdout, "keywords: [ ");
5353
G__print_keywords(stdout, NULL, FALSE);
54-
fprintf(stdout, "\n");
54+
fprintf(stdout, " ]");
5555
fprintf(stdout, "tags: [ ");
5656
G__print_keywords(stdout, NULL, FALSE);
5757
fprintf(stdout, " ]");

man/build_keywords.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,18 @@ def build_keywords(ext, main_path, addons_path):
106106
else:
107107
keys = []
108108
for line in lines:
109-
match = re.match(r"keywords:\s*(.*)", line)
109+
# We accept, but don't require, YAML inline list syntax.
110+
match = re.match(r"keywords:\s*\[\s*(.*)\s*\]\s*", line)
111+
if not match:
112+
match = re.match(r"keywords:\s*(.*)\s*", line)
110113
if match:
111114
text = match.group(1)
112115
if not text:
113116
print(
114117
f"Warning: Empty keyword list in {fname}", file=sys.stderr
115118
)
116119
break
120+
# We accept only non-quoted YAML strings.
117121
keys = [item.strip() for item in text.split(",")]
118122
break
119123

man/mkdocs/tags.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
Following is a list of relevant tags:
44

5-
<!-- material/tags -->
5+
<!-- material/tags { exclude: [unit test] } -->

0 commit comments

Comments
 (0)