|
1 | 1 | import os.path |
2 | 2 | from contextlib import contextmanager |
3 | | -from jinja2 import Environment, FileSystemLoader |
4 | 3 | from pathlib import Path |
5 | 4 | from tempfile import TemporaryDirectory |
6 | 5 | from typing import List, Optional |
| 6 | + |
| 7 | +from jinja2 import Environment, FileSystemLoader |
| 8 | + |
7 | 9 | from .utils import get_config |
8 | 10 |
|
9 | 11 | __all__ = ("generate_docs_configuration",) |
@@ -70,31 +72,33 @@ def generate_docs_configuration( |
70 | 72 | source_dir = os.path.curdir |
71 | 73 |
|
72 | 74 | configuration_args = {} |
73 | | - for f in ( |
74 | | - # autodoc/autodoc-pydantic |
75 | | - "autodoc_pydantic_model_show_config_summary", |
76 | | - "autodoc_pydantic_model_show_validator_summary", |
77 | | - "autodoc_pydantic_model_show_validator_members", |
78 | | - "autodoc_pydantic_field_list_validators", |
79 | | - "autodoc_pydantic_field_show_constraints", |
80 | | - "autodoc_pydantic_model_member_order", |
81 | | - "autodoc_pydantic_model_show_json", |
82 | | - "autodoc_pydantic_settings_show_json", |
83 | | - "autodoc_pydantic_model_show_field_summary", |
| 75 | + for config_option, default in { |
| 76 | + # sphinx generic |
| 77 | + "html_theme_options": {}, |
| 78 | + "html_static_path": [], |
| 79 | + "html_css_files": [], |
| 80 | + "html_js_files": [], |
| 81 | + "source_suffix": [], |
| 82 | + "exclude_patterns": [], |
| 83 | + "language": "en", |
| 84 | + "pygments_style": "sphinx", |
84 | 85 | # myst/myst-nb |
85 | | - "nb_execution_mode", |
86 | | - "nb_execution_excludepatterns", |
87 | | - ): |
88 | | - default_value = { |
89 | | - # autodoc/autodoc-pydantic |
90 | | - "autodoc_pydantic_model_member_order": '"bysource"', |
91 | | - "autodoc_pydantic_model_show_json": True, |
92 | | - # myst/myst-nb |
93 | | - "nb_execution_excludepatterns": [], |
94 | | - "nb_execution_mode": "off", |
95 | | - }.get(f, False) |
96 | | - config_value = get_config(section=f"{f}") |
97 | | - configuration_args[f] = default_value if config_value is None else config_value |
| 86 | + "myst_enable_extensions": ["colon_fence"], |
| 87 | + "myst_fence_as_directive": ["mermaid"], |
| 88 | + "nb_execution_mode": "off", |
| 89 | + "nb_execution_excludepatterns": [], |
| 90 | + # autodoc/autodoc-pydantic |
| 91 | + "autodoc_pydantic_model_show_config_summary": None, |
| 92 | + "autodoc_pydantic_model_show_validator_summary": None, |
| 93 | + "autodoc_pydantic_model_show_validator_members": None, |
| 94 | + "autodoc_pydantic_field_list_validators": None, |
| 95 | + "autodoc_pydantic_field_show_constraints": None, |
| 96 | + "autodoc_pydantic_model_member_order": "bysource", |
| 97 | + "autodoc_pydantic_model_show_json": True, |
| 98 | + "autodoc_pydantic_settings_show_json": None, |
| 99 | + "autodoc_pydantic_model_show_field_summary": None, |
| 100 | + }.items(): |
| 101 | + configuration_args[config_option] = get_config(section=config_option) or default |
98 | 102 | # create a temporary directory to store the conf.py file in |
99 | 103 | with TemporaryDirectory() as td: |
100 | 104 | templateEnv = Environment(loader=FileSystemLoader(searchpath=str(Path(__file__).parent.resolve()))) |
|
0 commit comments