|
7 | 7 | import os |
8 | 8 | import sys |
9 | 9 | from datetime import datetime |
| 10 | +import warnings |
10 | 11 |
|
| 12 | +import numpy as np |
| 13 | +import networkx as nx |
11 | 14 | import sphinx_gallery # noqa: F401 |
12 | | -from sphinx_gallery.sorting import ExampleTitleSortKey |
| 15 | +from sphinx_gallery.sorting import ExampleTitleSortKey, ExplicitOrder |
13 | 16 |
|
14 | 17 | # -- Path setup -------------------------------------------------------------- |
15 | 18 |
|
|
48 | 51 | "sphinx.ext.doctest", |
49 | 52 | "sphinx.ext.intersphinx", |
50 | 53 | "sphinx_issues", |
51 | | - "sphinx.ext.mathjax", |
52 | 54 | "sphinx.ext.viewcode", |
| 55 | + # "nbsphinx", # enables building Jupyter notebooks and rendering |
| 56 | + "sphinx.ext.mathjax", |
53 | 57 | "sphinx_gallery.gen_gallery", |
54 | 58 | "sphinxcontrib.bibtex", |
55 | 59 | "sphinx_copybutton", |
56 | 60 | "numpydoc", |
57 | | - "IPython.sphinxext.ipython_console_highlighting", |
58 | | - "nbsphinx", |
| 61 | + # "IPython.sphinxext.ipython_console_highlighting", |
59 | 62 | ] |
60 | 63 |
|
61 | 64 | # configure sphinx-copybutton |
|
106 | 109 | "attributes", |
107 | 110 | "dictionary", |
108 | 111 | "ArrayLike", |
109 | | - "nx.MixedEdgeGraph", |
| 112 | + "pywhy_nx.MixedEdgeGraph", |
110 | 113 | # pywhy-graphs |
111 | 114 | "causal", |
112 | 115 | "Node", |
|
161 | 164 | "ADMG": "pywhy_graphs.ADMG", |
162 | 165 | "PAG": "pywhy_graphs.PAG", |
163 | 166 | "CPDAG": "pywhy_graphs.CPDAG", |
| 167 | + "pywhy_nx.MixedEdgeGraph": "pywhy_graphs.networkx.MixedEdgeGraph", |
164 | 168 | # joblib |
165 | 169 | "joblib.Parallel": "joblib.Parallel", |
166 | 170 | # pandas |
|
182 | 186 | # directories to ignore when looking for source files. |
183 | 187 | # This pattern also affects html_static_path and html_extra_path. |
184 | 188 | exclude_patterns = [ |
185 | | - "auto_examples/index.rst", |
186 | 189 | "_build", |
187 | 190 | "Thumbs.db", |
188 | | - ".DS_Store", |
189 | 191 | "**.ipynb_checkpoints", |
190 | | - "auto_examples/*.rst", |
| 192 | + # "auto_examples/*.rst", |
| 193 | + # "auto_examples/index.rst", |
| 194 | + # "auto_examples/mixededge/index.rst", |
| 195 | + # "auto_examples/mixededge/*.rst", |
191 | 196 | ] |
192 | 197 |
|
193 | 198 | source_suffix = [".rst", ".md"] |
|
214 | 219 | # The master toctree document. |
215 | 220 | master_doc = "index" |
216 | 221 |
|
217 | | - |
218 | 222 | # -- Options for HTML output ------------------------------------------------- |
219 | 223 |
|
220 | 224 | # The theme to use for HTML and HTML Help pages. See the documentation for |
|
253 | 257 | scrapers = ("matplotlib",) |
254 | 258 |
|
255 | 259 | sphinx_gallery_conf = { |
| 260 | + # Modules for which function level galleries are created. In |
| 261 | + # this case sphinx_gallery and numpy in a tuple of strings. |
256 | 262 | "doc_module": "pywhy_graphs", |
| 263 | + # Insert links to documentation of objects in the examples |
257 | 264 | "reference_url": { |
258 | 265 | "pywhy_graphs": None, |
259 | 266 | }, |
260 | 267 | "backreferences_dir": "generated", |
261 | 268 | "plot_gallery": "True", # Avoid annoying Unicode/bool default warning |
262 | | - "within_subsection_order": ExampleTitleSortKey, |
263 | 269 | "examples_dirs": ["../examples"], |
264 | 270 | "gallery_dirs": ["auto_examples"], |
265 | | - "filename_pattern": "^((?!sgskip).)*$", |
| 271 | + "within_subsection_order": ExampleTitleSortKey, |
| 272 | + "subsection_order": ExplicitOrder( |
| 273 | + [ |
| 274 | + "../examples/mixededge", |
| 275 | + "../examples/intro", |
| 276 | + "../examples/visualization", |
| 277 | + ] |
| 278 | + ), |
| 279 | + # "filename_pattern": "^((?!sgskip).)*$", |
| 280 | + "filename_pattern": r"\.py", |
266 | 281 | "matplotlib_animations": True, |
267 | 282 | "compress_images": ("images", "thumbnails"), |
268 | 283 | "image_scrapers": scrapers, |
| 284 | + 'show_memory': not sys.platform.startswith(('win', 'darwin')), |
269 | 285 | } |
270 | 286 |
|
| 287 | +# Add pygraphviz png scraper, if available |
| 288 | +try: |
| 289 | + from pygraphviz.scraper import PNGScraper |
| 290 | + |
| 291 | + sphinx_gallery_conf["image_scrapers"] += (PNGScraper(),) |
| 292 | +except ImportError: |
| 293 | + pass |
| 294 | + |
271 | 295 | # Custom sidebar templates, maps document names to template names. |
272 | 296 | html_sidebars = { |
273 | 297 | "index": ["search-field.html"], |
| 298 | + "install": [], |
| 299 | + "tutorial": [], |
| 300 | + "auto_examples/index": [], |
274 | 301 | } |
275 | 302 |
|
276 | 303 | html_context = { |
|
286 | 313 | nitpick_ignore = [ |
287 | 314 | ("py:obj", "nx.MixedEdgeGraph"), |
288 | 315 | ("py:obj", "networkx.MixedEdgeGraph"), |
| 316 | + ("py:obj", "pywhy_graphs.networkx.MixedEdgeGraph"), |
| 317 | + ("py:obj", "pywhy_nx.MixedEdgeGraph"), |
289 | 318 | ("py:class", "networkx.classes.mixededge.MixedEdgeGraph"), |
290 | 319 | ("py:class", "numpy._typing._array_like._SupportsArray"), |
291 | 320 | ("py:class", "numpy._typing._nested_sequence._NestedSequence"), |
292 | 321 | ] |
| 322 | + |
| 323 | + |
| 324 | +# -- Warnings management ----------------------------------------------------- |
| 325 | +def setup(app): |
| 326 | + # Ignore .ipynb files |
| 327 | + app.registry.source_suffix.pop(".ipynb", None) |
| 328 | + |
| 329 | +warnings.filterwarnings("ignore", category=UserWarning) |
0 commit comments