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])
| 169 | |
| 170 | |
| 171 | def 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 | |
| 202 | def check_stubs(ctx: Context, files: list[pathlib.Path]) -> int: |
no test coverage detected