ceb474bb9e
Batch of docs backports: * docs: Clarify include_task v import_tasks with conditionals (#43856) (cherry picked from commit6be42a2a0e
) * Add single quotes around package name (#45152) (cherry picked from commit0d81386144
) * prefer ansible_facts namespace and dict notation (#44980) (cherry picked from commit44510448b0
) * fix cherrypick conflict - scenario_guides * Update implicit_localhost.rst (#45455) (cherry picked from commitf68cd1acc6
) * updated fbsd install instructions (#45309) (cherry picked from commite9c2695ce7
) * Change "Defaulting Undefined Variables" (#41379) (cherry picked from commite35c4be1c1
) * adds license details to dev guide pages (#45574) (cherry picked from commit6e68d77f6d
) * FAQ: fix a typo, add link to 'vars' lookup (#42412) (cherry picked from commit95649dc793
) * Fix link and toctree (#45595) (cherry picked from commit6999bf318f
) * Improve the local toctree (and title) (#45590) (cherry picked from commitafea00fa9f
) * Add undocumented configuration parameter and explain in porting guide (#36059) (cherry picked from commita892a6ef03
) * Simplify PPA installation for Ubuntu (#45690) (cherry picked from commit78e9f452a5
) * adding git+ssh uri scheme (#36025) (cherry picked from commit84a4257774
) * Add workaround for non-standard kerberos environments (#41465) (cherry picked from commit4e532e0ad9
) * Restore license agreement (#45809) (cherry picked from commitf430f60541
) * partial cherry-pick - lenovo doc update PR 45483
99 lines
3.6 KiB
Python
Executable file
99 lines
3.6 KiB
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import os
|
|
import re
|
|
import subprocess
|
|
|
|
|
|
def main():
|
|
base_dir = os.getcwd() + os.sep
|
|
docs_dir = os.path.abspath('docs/docsite')
|
|
cmd = ['make', 'singlehtmldocs']
|
|
|
|
sphinx = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=docs_dir)
|
|
stdout, stderr = sphinx.communicate()
|
|
|
|
if sphinx.returncode != 0:
|
|
raise subprocess.CalledProcessError(sphinx.returncode, cmd, output=stdout, stderr=stderr)
|
|
|
|
with open('docs/docsite/rst_warnings', 'r') as warnings_fd:
|
|
output = warnings_fd.read().strip()
|
|
lines = output.splitlines()
|
|
|
|
known_warnings = {
|
|
'block-quote-missing-blank-line': r'^Block quote ends without a blank line; unexpected unindent.$',
|
|
'literal-block-lex-error': r'^Could not lex literal_block as "[^"]*". Highlighting skipped.$',
|
|
'duplicate-label': r'^duplicate label ',
|
|
'undefined-label': r'undefined label: ',
|
|
'unknown-document': r'unknown document: ',
|
|
'toc-tree-missing-document': r'toctree contains reference to nonexisting document ',
|
|
'reference-target-not-found': r'[^ ]* reference target not found: ',
|
|
'not-in-toc-tree': r"document isn't included in any toctree$",
|
|
'unexpected-indentation': r'^Unexpected indentation.$',
|
|
'definition-list-missing-blank-line': r'^Definition list ends without a blank line; unexpected unindent.$',
|
|
'explicit-markup-missing-blank-line': r'Explicit markup ends without a blank line; unexpected unindent.$',
|
|
'toc-tree-glob-pattern-no-match': r"^toctree glob pattern '[^']*' didn't match any documents$",
|
|
'unknown-interpreted-text-role': '^Unknown interpreted text role "[^"]*".$',
|
|
}
|
|
|
|
ignore_codes = [
|
|
'reference-target-not-found',
|
|
]
|
|
|
|
used_ignore_codes = set()
|
|
|
|
for line in lines:
|
|
match = re.search('^(?P<path>[^:]+):((?P<line>[0-9]+):)?((?P<column>[0-9]+):)? (?P<level>WARNING|ERROR): (?P<message>.*)$', line)
|
|
|
|
if not match:
|
|
path = 'docs/docsite/rst/index.rst'
|
|
lineno = 0
|
|
column = 0
|
|
code = 'unknown'
|
|
message = line
|
|
|
|
# surface unknown lines while filtering out known lines to avoid excessive output
|
|
print('%s:%d:%d: %s: %s' % (path, lineno, column, code, message))
|
|
continue
|
|
|
|
path = match.group('path')
|
|
lineno = int(match.group('line') or 0)
|
|
column = int(match.group('column') or 0)
|
|
level = match.group('level').lower()
|
|
message = match.group('message')
|
|
|
|
path = os.path.abspath(path)
|
|
|
|
if path.startswith(base_dir):
|
|
path = path[len(base_dir):]
|
|
|
|
if path.startswith('rst/'):
|
|
path = 'docs/docsite/' + path # fix up paths reported relative to `docs/docsite/`
|
|
|
|
if level == 'warning':
|
|
code = 'warning'
|
|
|
|
for label, pattern in known_warnings.items():
|
|
if re.search(pattern, message):
|
|
code = label
|
|
break
|
|
else:
|
|
code = 'error'
|
|
|
|
if code == 'not-in-toc-tree' and path.startswith('docs/docsite/rst/modules/'):
|
|
continue # modules are not expected to be in the toc tree
|
|
|
|
if code in ignore_codes:
|
|
used_ignore_codes.add(code)
|
|
continue # ignore these codes
|
|
|
|
print('%s:%d:%d: %s: %s' % (path, lineno, column, code, message))
|
|
|
|
unused_ignore_codes = set(ignore_codes) - used_ignore_codes
|
|
|
|
for code in unused_ignore_codes:
|
|
print('test/sanity/code-smell/docs-build.py:0:0: remove `%s` from the `ignore_codes` list as it is no longer needed' % code)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|