Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: use parser_yaml extension to handle Netlink specs

Instead of manually calling ynl_gen_rst.py, use a Sphinx extension.
This way, no .rst files would be written to the Kernel source
directories.

We are using here a toctree with :glob: property. This way, there
is no need to touch the netlink/specs/index.rst file every time
a new Netlink spec is added/renamed/removed.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>

+16 -27
-17
Documentation/Makefile
··· 104 104 cp $(if $(patsubst /%,,$(DOCS_CSS)),$(abspath $(srctree)/$(DOCS_CSS)),$(DOCS_CSS)) $(BUILDDIR)/$3/_static/; \ 105 105 fi 106 106 107 - YNL_INDEX:=$(srctree)/Documentation/networking/netlink_spec/index.rst 108 - YNL_RST_DIR:=$(srctree)/Documentation/networking/netlink_spec 109 - YNL_YAML_DIR:=$(srctree)/Documentation/netlink/specs 110 - YNL_TOOL:=$(srctree)/tools/net/ynl/pyynl/ynl_gen_rst.py 111 - 112 - YNL_RST_FILES_TMP := $(patsubst %.yaml,%.rst,$(wildcard $(YNL_YAML_DIR)/*.yaml)) 113 - YNL_RST_FILES := $(patsubst $(YNL_YAML_DIR)%,$(YNL_RST_DIR)%, $(YNL_RST_FILES_TMP)) 114 - 115 - $(YNL_INDEX): $(YNL_RST_FILES) 116 - $(Q)$(YNL_TOOL) -o $@ -x 117 - 118 - $(YNL_RST_DIR)/%.rst: $(YNL_YAML_DIR)/%.yaml $(YNL_TOOL) 119 - $(Q)$(YNL_TOOL) -i $< -o $@ 120 - 121 - htmldocs texinfodocs latexdocs epubdocs xmldocs: $(YNL_INDEX) 122 - 123 107 htmldocs: 124 108 @$(srctree)/scripts/sphinx-pre-install --version-check 125 109 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) ··· 170 186 $(Q)cd $(srctree);scripts/documentation-file-ref-check 171 187 172 188 cleandocs: 173 - $(Q)rm -f $(YNL_INDEX) $(YNL_RST_FILES) 174 189 $(Q)rm -rf $(BUILDDIR) 175 190 $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media clean 176 191
+15 -5
Documentation/conf.py
··· 42 42 dyn_include_patterns = [] 43 43 dyn_exclude_patterns = ["output"] 44 44 45 + # Currently, only netlink/specs has a parser for yaml. 46 + # Prefer using include patterns if available, as it is faster 47 + if has_include_patterns: 48 + dyn_include_patterns.append("netlink/specs/*.yaml") 49 + else: 50 + dyn_exclude_patterns.append("netlink/*.yaml") 51 + dyn_exclude_patterns.append("devicetree/bindings/**.yaml") 52 + dyn_exclude_patterns.append("core-api/kho/bindings/**.yaml") 53 + 45 54 # Properly handle include/exclude patterns 46 55 # ---------------------------------------- 47 56 ··· 111 102 "kernel_include", 112 103 "kfigure", 113 104 "maintainers_include", 105 + "parser_yaml", 114 106 "rstFlatTable", 115 107 "sphinx.ext.autosectionlabel", 116 108 "sphinx.ext.ifconfig", 117 109 "translations", 118 110 ] 119 - 120 111 # Since Sphinx version 3, the C function parser is more pedantic with regards 121 112 # to type checking. Due to that, having macros at c:function cause problems. 122 113 # Those needed to be escaped by using c_id_attributes[] array ··· 213 204 # Add any paths that contain templates here, relative to this directory. 214 205 templates_path = ["sphinx/templates"] 215 206 216 - # The suffix(es) of source filenames. 217 - # You can specify multiple suffix as a list of string: 218 - # source_suffix = ['.rst', '.md'] 219 - source_suffix = '.rst' 207 + # The suffixes of source filenames that will be automatically parsed 208 + source_suffix = { 209 + ".rst": "restructuredtext", 210 + ".yaml": "yaml", 211 + } 220 212 221 213 # The encoding of source files. 222 214 # source_encoding = 'utf-8-sig'
+1 -1
Documentation/networking/index.rst
··· 57 57 filter 58 58 generic-hdlc 59 59 generic_netlink 60 - netlink_spec/index 60 + ../netlink/specs/index 61 61 gen_stats 62 62 gtp 63 63 ila