Skip to content

Commit

Permalink
[Change] remove blank ps (PaddlePaddle#6294)
Browse files Browse the repository at this point in the history
  • Loading branch information
megemini authored Nov 7, 2023
1 parent 3117adc commit 45df43e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions ci_scripts/doc-build-config/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,17 @@ def remove_doctest_directives(app, what, name, obj, options, lines):
"""
Remove `doctest` directives from docstring
"""
pattern_doctest = re.compile(r"\s*>>>\s*#\s*doctest:\s*.*")

# Modify the lines inplace
lines[:] = [
line
for line in lines
if not (pattern_doctest.match(line) or line.strip() == ">>>")
]
# remove doctest directive
pattern_doctest = re.compile(r"\s*>>>\s*#\s*x?doctest:\s*.*")
lines[:] = [line for line in lines if not pattern_doctest.match(line)]

# remove blank ps(`>>>`)
lines[:] = [line for line in lines if not line.strip() == ">>>"]

# make sure there is a blank line at the end
if lines and lines[-1]:
lines.append('')


def setup(app):
Expand All @@ -390,5 +393,5 @@ def setup(app):
)
app.add_transform(AutoStructify)

# remove doctest directives
# remove doctest directives and blank ps
app.connect("autodoc-process-docstring", remove_doctest_directives)

0 comments on commit 45df43e

Please sign in to comment.