Skip to content

CI/DOC: Add option to build whatsnew #39182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ def __init__(
self,
num_jobs=0,
include_api=True,
whatsnew=False,
single_doc=None,
verbosity=0,
warnings_are_errors=False,
):
self.num_jobs = num_jobs
self.include_api = include_api
self.whatsnew = whatsnew
self.verbosity = verbosity
self.warnings_are_errors = warnings_are_errors

Expand All @@ -56,6 +58,8 @@ def __init__(
os.environ["SPHINX_PATTERN"] = single_doc
elif not include_api:
os.environ["SPHINX_PATTERN"] = "-api"
elif whatsnew:
os.environ["SPHINX_PATTERN"] = "whatsnew"

self.single_doc_html = None
if single_doc and single_doc.endswith(".rst"):
Expand Down Expand Up @@ -235,6 +239,9 @@ def html(self):
self._open_browser(self.single_doc_html)
else:
self._add_redirects()
if self.whatsnew:
self._open_browser(os.path.join("whatsnew", "index.html"))

return ret_code

def latex(self, force=False):
Expand Down Expand Up @@ -302,6 +309,12 @@ def main():
argparser.add_argument(
"--no-api", default=False, help="omit api and autosummary", action="store_true"
)
argparser.add_argument(
"--whatsnew",
default=False,
help="only build whatsnew (and api for links)",
action="store_true",
)
argparser.add_argument(
"--single",
metavar="FILENAME",
Expand Down Expand Up @@ -353,6 +366,7 @@ def main():
builder = DocBuilder(
args.num_jobs,
not args.no_api,
args.whatsnew,
args.single,
args.verbosity,
args.warnings_are_errors,
Expand Down
12 changes: 9 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
# (e.g. '10min.rst' or 'pandas.DataFrame.head')
source_path = os.path.dirname(os.path.abspath(__file__))
pattern = os.environ.get("SPHINX_PATTERN")
single_doc = pattern is not None and pattern != "-api"
include_api = pattern != "-api"
single_doc = pattern is not None and pattern not in ("-api", "whatsnew")
include_api = pattern is None or pattern == "whatsnew"
if pattern:
for dirname, dirs, fnames in os.walk(source_path):
reldir = os.path.relpath(dirname, source_path)
Expand All @@ -104,7 +104,13 @@
continue
elif pattern == "-api" and reldir.startswith("reference"):
exclude_patterns.append(fname)
elif pattern != "-api" and fname != pattern:
elif (
pattern == "whatsnew"
and not reldir.startswith("reference")
and reldir != "whatsnew"
):
exclude_patterns.append(fname)
elif single_doc and fname != pattern:
exclude_patterns.append(fname)

with open(os.path.join(source_path, "index.rst.template")) as f:
Expand Down
4 changes: 4 additions & 0 deletions doc/source/development/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ reducing the turn-around time for checking your changes.
python make.py clean
python make.py --single pandas.DataFrame.join

# compile whatsnew and API section (to resolve links in the whatsnew)
python make.py clean
python make.py --whatsnew

For comparison, a full documentation build may take 15 minutes, but a single
section may take 15 seconds. Subsequent builds, which only process portions
you have changed, will be faster.
Expand Down