|
77 | 77 | try: |
78 | 78 | import nbconvert |
79 | 79 | except ImportError: |
80 | | - logger.warn("nbconvert not installed. Skipping notebooks.") |
| 80 | + logger.warning("nbconvert not installed. Skipping notebooks.") |
81 | 81 | exclude_patterns.append("**/*.ipynb") |
82 | 82 | else: |
83 | 83 | try: |
84 | 84 | nbconvert.utils.pandoc.get_pandoc_version() |
85 | 85 | except nbconvert.utils.pandoc.PandocMissing: |
86 | | - logger.warn("Pandoc not installed. Skipping notebooks.") |
| 86 | + logger.warning("Pandoc not installed. Skipping notebooks.") |
87 | 87 | exclude_patterns.append("**/*.ipynb") |
88 | 88 |
|
89 | 89 | # sphinx_pattern can be '-api' to exclude the API pages, |
90 | 90 | # the path to a file, or a Python object |
91 | 91 | # (e.g. '10min.rst' or 'pandas.DataFrame.head') |
92 | 92 | source_path = os.path.dirname(os.path.abspath(__file__)) |
93 | 93 | pattern = os.environ.get("SPHINX_PATTERN") |
| 94 | +single_doc = pattern is not None and pattern != "-api" |
| 95 | +include_api = pattern != "-api" |
94 | 96 | if pattern: |
95 | 97 | for dirname, dirs, fnames in os.walk(source_path): |
| 98 | + reldir = os.path.relpath(dirname, source_path) |
96 | 99 | for fname in fnames: |
97 | 100 | if os.path.splitext(fname)[-1] in (".rst", ".ipynb"): |
98 | 101 | fname = os.path.relpath(os.path.join(dirname, fname), source_path) |
99 | 102 |
|
100 | 103 | if fname == "index.rst" and os.path.abspath(dirname) == source_path: |
101 | 104 | continue |
102 | | - elif pattern == "-api" and dirname == "reference": |
| 105 | + elif pattern == "-api" and reldir.startswith("reference"): |
103 | 106 | exclude_patterns.append(fname) |
104 | 107 | elif pattern != "-api" and fname != pattern: |
105 | 108 | exclude_patterns.append(fname) |
|
109 | 112 | with open(os.path.join(source_path, "index.rst"), "w") as f: |
110 | 113 | f.write( |
111 | 114 | t.render( |
112 | | - include_api=pattern is None, |
113 | | - single_doc=(pattern if pattern is not None and pattern != "-api" else None), |
| 115 | + include_api=include_api, |
| 116 | + single_doc=(pattern if single_doc else None), |
114 | 117 | ) |
115 | 118 | ) |
116 | | -autosummary_generate = True if pattern is None else ["index"] |
| 119 | +autosummary_generate = True if include_api else ["index"] |
117 | 120 | autodoc_typehints = "none" |
118 | 121 |
|
119 | 122 | # numpydoc |
|
315 | 318 | # ... and each of its public methods |
316 | 319 | moved_api_pages.append((f"{old}.{method}", f"{new}.{method}")) |
317 | 320 |
|
318 | | -if pattern is None: |
| 321 | +if include_api: |
319 | 322 | html_additional_pages = { |
320 | 323 | "generated/" + page[0]: "api_redirect.html" for page in moved_api_pages |
321 | 324 | } |
|
411 | 414 | # latex_use_modindex = True |
412 | 415 |
|
413 | 416 |
|
414 | | -if pattern is None: |
| 417 | +if include_api: |
415 | 418 | intersphinx_mapping = { |
416 | 419 | "dateutil": ("https://dateutil.readthedocs.io/en/latest/", None), |
417 | 420 | "matplotlib": ("https://matplotlib.org/", None), |
|
0 commit comments