MCPcopy
hub / github.com/saltstack/salt / check_inline_markup

Function check_inline_markup

tools/precommit/docs.py:171–199  ·  view source on GitHub ↗

Check docstring for :doc: usage We should not be using the ``:doc:`` inline markup option when cross-referencing locations. Use ``:ref:`` or ``:mod:`` instead. This task checks for reference to ``:doc:`` usage. See Issue #12788 for more information. https://github.com/sa

(ctx: Context, files: list[pathlib.Path])

Source from the content-addressed store, hash-verified

169
170
171def check_inline_markup(ctx: Context, files: list[pathlib.Path]) -> int:
172 """
173 Check docstring for :doc: usage
174
175 We should not be using the ``:doc:`` inline markup option when
176 cross-referencing locations. Use ``:ref:`` or ``:mod:`` instead.
177
178 This task checks for reference to ``:doc:`` usage.
179
180 See Issue #12788 for more information.
181
182 https://github.com/saltstack/salt/issues/12788
183 """
184 files = build_python_module_paths(files)
185
186 exitcode = 0
187 for path in files:
188 module = ast.parse(path.read_text(), filename=str(path))
189 funcdefs = [node for node in module.body if isinstance(node, ast.FunctionDef)]
190 for funcdef in funcdefs:
191 docstring = ast.get_docstring(funcdef, clean=True)
192 if not docstring:
193 continue
194 if ":doc:" in docstring:
195 ctx.error(
196 f"The {funcdef.name} function in {path} contains ':doc:' usage"
197 )
198 exitcode += 1
199 return exitcode
200
201
202def check_stubs(ctx: Context, files: list[pathlib.Path]) -> int:

Callers 1

checkFunction · 0.85

Calls 4

parseMethod · 0.45
read_textMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected