Skip to content

Commit 3b36529

Browse files
authored
CI/DOC: Add option to build whatsnew (#39182)
1 parent a862060 commit 3b36529

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

doc/make.py

+14
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ def __init__(
4141
self,
4242
num_jobs=0,
4343
include_api=True,
44+
whatsnew=False,
4445
single_doc=None,
4546
verbosity=0,
4647
warnings_are_errors=False,
4748
):
4849
self.num_jobs = num_jobs
4950
self.include_api = include_api
51+
self.whatsnew = whatsnew
5052
self.verbosity = verbosity
5153
self.warnings_are_errors = warnings_are_errors
5254

@@ -56,6 +58,8 @@ def __init__(
5658
os.environ["SPHINX_PATTERN"] = single_doc
5759
elif not include_api:
5860
os.environ["SPHINX_PATTERN"] = "-api"
61+
elif whatsnew:
62+
os.environ["SPHINX_PATTERN"] = "whatsnew"
5963

6064
self.single_doc_html = None
6165
if single_doc and single_doc.endswith(".rst"):
@@ -235,6 +239,9 @@ def html(self):
235239
self._open_browser(self.single_doc_html)
236240
else:
237241
self._add_redirects()
242+
if self.whatsnew:
243+
self._open_browser(os.path.join("whatsnew", "index.html"))
244+
238245
return ret_code
239246

240247
def latex(self, force=False):
@@ -302,6 +309,12 @@ def main():
302309
argparser.add_argument(
303310
"--no-api", default=False, help="omit api and autosummary", action="store_true"
304311
)
312+
argparser.add_argument(
313+
"--whatsnew",
314+
default=False,
315+
help="only build whatsnew (and api for links)",
316+
action="store_true",
317+
)
305318
argparser.add_argument(
306319
"--single",
307320
metavar="FILENAME",
@@ -353,6 +366,7 @@ def main():
353366
builder = DocBuilder(
354367
args.num_jobs,
355368
not args.no_api,
369+
args.whatsnew,
356370
args.single,
357371
args.verbosity,
358372
args.warnings_are_errors,

doc/source/conf.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191
# (e.g. '10min.rst' or 'pandas.DataFrame.head')
9292
source_path = os.path.dirname(os.path.abspath(__file__))
9393
pattern = os.environ.get("SPHINX_PATTERN")
94-
single_doc = pattern is not None and pattern != "-api"
95-
include_api = pattern != "-api"
94+
single_doc = pattern is not None and pattern not in ("-api", "whatsnew")
95+
include_api = pattern is None or pattern == "whatsnew"
9696
if pattern:
9797
for dirname, dirs, fnames in os.walk(source_path):
9898
reldir = os.path.relpath(dirname, source_path)
@@ -104,7 +104,13 @@
104104
continue
105105
elif pattern == "-api" and reldir.startswith("reference"):
106106
exclude_patterns.append(fname)
107-
elif pattern != "-api" and fname != pattern:
107+
elif (
108+
pattern == "whatsnew"
109+
and not reldir.startswith("reference")
110+
and reldir != "whatsnew"
111+
):
112+
exclude_patterns.append(fname)
113+
elif single_doc and fname != pattern:
108114
exclude_patterns.append(fname)
109115

110116
with open(os.path.join(source_path, "index.rst.template")) as f:

doc/source/development/contributing.rst

+4
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,10 @@ reducing the turn-around time for checking your changes.
604604
python make.py clean
605605
python make.py --single pandas.DataFrame.join
606606

607+
# compile whatsnew and API section (to resolve links in the whatsnew)
608+
python make.py clean
609+
python make.py --whatsnew
610+
607611
For comparison, a full documentation build may take 15 minutes, but a single
608612
section may take 15 seconds. Subsequent builds, which only process portions
609613
you have changed, will be faster.

0 commit comments

Comments
 (0)