|
1 | 1 | """
|
2 | 2 | Sphinx documentation configuration file.
|
| 3 | +
|
| 4 | +Reference: https://www.sphinx-doc.org/en/master/usage/configuration.html |
3 | 5 | """
|
4 | 6 |
|
5 | 7 | import datetime
|
|
10 | 12 | from pygmt.clib import required_gmt_version
|
11 | 13 | from pygmt.sphinx_gallery import PyGMTScraper
|
12 | 14 |
|
13 |
| -# Dictionary for dependency name and minimum required versions |
| 15 | +# Dictionary for dependency name and minimum required versions. |
14 | 16 | requirements = {
|
15 | 17 | Requirement(requirement).name: str(Requirement(requirement).specifier)
|
16 | 18 | for requirement in importlib.metadata.requires("pygmt")
|
|
21 | 23 | "gmt": f">={required_gmt_version}",
|
22 | 24 | }
|
23 | 25 | )
|
| 26 | +# Is a development version or not. |
| 27 | +isdev = "dev" in __version__ or __version__ == "unknown" |
| 28 | +# Some variables. |
| 29 | +repository = "GenericMappingTools/pygmt" |
| 30 | +repository_url = f"https://github.com/{repository}" |
| 31 | +doc_url = "https://pygmt.org/" |
| 32 | +if __commit__: |
| 33 | + commit_link = f'<a href="{repository_url}/commit/{__commit__}">{__commit__[:8]}</a>' |
| 34 | +else: |
| 35 | + commit_link = ( |
| 36 | + f'<a href="{repository_url}/releases/tag/{__version__}">{__version__}</a>' |
| 37 | + ) |
| 38 | + |
| 39 | +# Projection information. |
| 40 | +project = "PyGMT" |
| 41 | +author = "The PyGMT Developers" |
| 42 | +copyright = f"2017-{datetime.date.today().year}, {author}" # noqa: A001 |
| 43 | +version = "dev" if isdev else __version__ |
| 44 | +release = __version__ |
24 | 45 |
|
| 46 | +# General configurations. |
| 47 | +needs_sphinx = "6.2" |
25 | 48 | extensions = [
|
26 | 49 | "myst_nb",
|
27 | 50 | "sphinx.ext.autodoc",
|
|
39 | 62 | "sphinx_gallery.gen_gallery",
|
40 | 63 | "sphinxcontrib.cairosvgconverter",
|
41 | 64 | ]
|
42 |
| - |
43 |
| -# Suppress warnings |
| 65 | +# Options for highlighting. |
| 66 | +pygments_style = "default" |
| 67 | +# Options for object signatures. |
| 68 | +add_function_parentheses = False |
| 69 | +# Options for source files. |
| 70 | +exclude_patterns = [ |
| 71 | + "_build", |
| 72 | + "**.ipynb_checkpoints", |
| 73 | + # Workaround from https://github.com/executablebooks/MyST-NB/issues/363 to prevent |
| 74 | + # MyST-NB from parsing the .ipynb and .py files generated by Sphinx-Gallery. |
| 75 | + "intro/**.ipynb", |
| 76 | + "tutorials/**.ipynb", |
| 77 | + "gallery/**.ipynb", |
| 78 | + "projections/**.ipynb", |
| 79 | + "intro/**.py", |
| 80 | + "tutorials/**.py", |
| 81 | + "gallery/**.py", |
| 82 | + "projections/**.py", |
| 83 | +] |
| 84 | +# Options for source files. |
| 85 | +source_suffix = ".rst" |
| 86 | +source_encoding = "utf-8-sig" |
| 87 | +root_doc = "index" |
| 88 | +# Options for templating. |
| 89 | +templates_path = ["_templates"] |
| 90 | +# Options for warning control. |
44 | 91 | suppress_warnings = [
|
45 | 92 | "myst.header", # Document headings start at H2, not H1
|
46 | 93 | ]
|
47 | 94 |
|
| 95 | +# Options for autosummary. |
48 | 96 | # Autosummary pages will be generated by sphinx-autogen instead of sphinx-build
|
49 | 97 | autosummary_generate = []
|
50 | 98 |
|
51 |
| -# Auto-generate header anchors with MyST parser |
52 |
| -myst_heading_anchors = 4 |
53 |
| -# MyST extensions |
54 |
| -# Reference: https://myst-parser.readthedocs.io/en/latest/syntax/optional.html |
55 |
| -myst_enable_extensions = [ |
56 |
| - "attrs_inline", # Allow inline attributes after images |
57 |
| - "colon_fence", # Allow code fences using colons |
58 |
| - "substitution", # Allow substitutions |
59 |
| -] |
60 |
| -# These enable substitutions using {{ key }} in the Markdown files |
61 |
| -myst_substitutions = { |
62 |
| - "requires": requirements, |
63 |
| -} |
64 |
| - |
65 |
| -# Configure MyST-NB |
66 |
| -# Reference: https://myst-nb.readthedocs.io/en/latest/configuration.html |
67 |
| -nb_render_markdown_format = "myst" # Format for text/markdown rendering |
68 |
| - |
69 |
| -# Render the return argument and attribute lists in the same way as the parameter lists |
70 |
| -napoleon_use_rtype = False |
71 |
| -napoleon_use_ivar = True |
72 |
| - |
73 |
| -# Configure sphinx_auto_typehints |
74 |
| -typehints_defaults = "comma" |
75 |
| - |
76 |
| -# Define links to GMT docs |
| 99 | +# Options for extlinks. |
77 | 100 | extlinks = {
|
78 | 101 | "gmt-docs": ("https://docs.generic-mapping-tools.org/6.5/%s", None),
|
79 | 102 | "gmt-term": ("https://docs.generic-mapping-tools.org/6.5/gmt.conf#term-%s", "%s"),
|
80 | 103 | "gmt-datasets": ("https://www.generic-mapping-tools.org/remote-datasets/%s", None),
|
81 | 104 | }
|
82 | 105 |
|
83 |
| -# Configure intersphinx |
| 106 | +# Options for intersphinx. |
84 | 107 | intersphinx_mapping = {
|
85 | 108 | "contextily": ("https://contextily.readthedocs.io/en/stable/", None),
|
86 | 109 | "geopandas": ("https://geopandas.org/en/stable/", None),
|
|
94 | 117 | "xyzservices": ("https://xyzservices.readthedocs.io/en/stable", None),
|
95 | 118 | }
|
96 | 119 |
|
97 |
| -# Configure sphinx-copybutton |
| 120 | +# Options for napoleon. |
| 121 | +# Render the return argument and attribute lists in the same way as the parameter lists. |
| 122 | +napoleon_use_rtype = False |
| 123 | +napoleon_use_ivar = True |
| 124 | + |
| 125 | +# Options for sphinx-copybutton. |
98 | 126 | # Reference: https://sphinx-copybutton.readthedocs.io
|
99 | 127 | copybutton_prompt_text = r">>> |\.\.\. "
|
100 | 128 | copybutton_prompt_is_regexp = True
|
101 | 129 | copybutton_only_copy_prompt_lines = True
|
102 | 130 | copybutton_remove_prompts = True
|
103 | 131 |
|
| 132 | +# Options for MyST. |
| 133 | +myst_heading_anchors = 4 # Auto-generate header anchors with MyST parser |
| 134 | +# MyST extensions: https://myst-parser.readthedocs.io/en/latest/syntax/optional.html |
| 135 | +myst_enable_extensions = [ |
| 136 | + "attrs_inline", # Allow inline attributes after images |
| 137 | + "colon_fence", # Allow code fences using colons |
| 138 | + "substitution", # Allow substitutions |
| 139 | +] |
| 140 | +# Enable substitutions using {{ key }} in the Markdown files |
| 141 | +myst_substitutions = { |
| 142 | + "requires": requirements, |
| 143 | +} |
| 144 | + |
| 145 | +# Options for MyST-NB. |
| 146 | +# Reference: https://myst-nb.readthedocs.io/en/latest/configuration.html |
| 147 | +nb_render_markdown_format = "myst" # Format for text/markdown rendering |
| 148 | + |
| 149 | +# Options for sphinx_auto_typehints. |
| 150 | +typehints_defaults = "comma" |
| 151 | + |
| 152 | +# Options for Sphinx-Gallery. |
| 153 | +# Reference: https://sphinx-gallery.readthedocs.io/en/latest/configuration.html |
104 | 154 | sphinx_gallery_conf = {
|
105 | 155 | # Set paths to your examples scripts
|
106 | 156 | "examples_dirs": [
|
|
151 | 201 | "nested_sections": False,
|
152 | 202 | }
|
153 | 203 |
|
154 |
| -# Configure Sphinx project |
155 |
| -templates_path = ["_templates"] |
156 |
| -exclude_patterns = [ |
157 |
| - "_build", |
158 |
| - "**.ipynb_checkpoints", |
159 |
| - # Workaround from https://github.com/executablebooks/MyST-NB/issues/363 to prevent |
160 |
| - # MyST-NB from parsing the .ipynb and .py files generated by Sphinx-Gallery. |
161 |
| - "intro/**.ipynb", |
162 |
| - "tutorials/**.ipynb", |
163 |
| - "gallery/**.ipynb", |
164 |
| - "projections/**.ipynb", |
165 |
| - "intro/**.py", |
166 |
| - "tutorials/**.py", |
167 |
| - "gallery/**.py", |
168 |
| - "projections/**.py", |
169 |
| -] |
170 |
| - |
171 |
| -source_suffix = ".rst" |
172 |
| -needs_sphinx = "6.2" |
173 |
| -# Encoding of source files |
174 |
| -source_encoding = "utf-8-sig" |
175 |
| -root_doc = "index" |
176 |
| - |
177 |
| -# General information about the project |
178 |
| -year = datetime.date.today().year |
179 |
| -project = "PyGMT" |
180 |
| -copyright = f"2017-{year}, The PyGMT Developers" # noqa: A001 |
181 |
| -if len(__version__.split("+")) > 1 or __version__ == "unknown": |
182 |
| - version = "dev" |
183 |
| - # Set base URL for dev version |
184 |
| - html_baseurl = "https://pygmt.org/dev/" |
185 |
| -else: |
186 |
| - version = __version__ |
187 |
| - # Set base URL for stable version |
188 |
| - html_baseurl = "https://pygmt.org/latest/" |
189 |
| -release = __version__ |
190 |
| - |
191 |
| -html_last_updated_fmt = "%b %d, %Y" |
192 |
| -html_title = "PyGMT" |
193 |
| -html_short_title = "PyGMT" |
| 204 | +# Options for HTML output. |
| 205 | +html_theme = "sphinx_rtd_theme" |
| 206 | +html_theme_options = {} |
| 207 | +html_title = project |
| 208 | +html_short_title = project |
| 209 | +html_baseurl = f"{doc_url}/dev/" if isdev else f"{doc_url}/latest/" |
194 | 210 | html_logo = ""
|
195 | 211 | html_favicon = "_static/favicon.png"
|
196 |
| -html_static_path = ["_static"] |
197 | 212 | html_css_files = ["style.css"]
|
| 213 | +html_static_path = ["_static"] |
198 | 214 | html_extra_path = []
|
199 |
| -pygments_style = "default" |
200 |
| -add_function_parentheses = False |
| 215 | +html_last_updated_fmt = "%b %d, %Y" |
201 | 216 | html_show_sourcelink = False
|
202 |
| -html_show_sphinx = False |
203 | 217 | html_show_copyright = True
|
204 |
| - |
205 |
| -# Configure theme |
206 |
| -html_theme = "sphinx_rtd_theme" |
207 |
| -html_theme_options = {} |
208 |
| -repository = "GenericMappingTools/pygmt" |
209 |
| -repository_url = "https://github.com/GenericMappingTools/pygmt" |
210 |
| -if __commit__: |
211 |
| - commit_link = f'<a href="{repository_url}/commit/{__commit__}">{__commit__[:8]}</a>' |
212 |
| -else: |
213 |
| - commit_link = ( |
214 |
| - f'<a href="{repository_url}/releases/tag/{__version__}">{__version__}</a>' |
215 |
| - ) |
| 218 | +html_show_sphinx = False |
216 | 219 | html_context = {
|
217 | 220 | "menu_links": [
|
218 | 221 | (
|
|
247 | 250 | "commit": commit_link,
|
248 | 251 | }
|
249 | 252 |
|
250 |
| -# Configurations for LaTeX |
| 253 | +# Options for LaTeX output. |
251 | 254 | latex_engine = "xelatex"
|
0 commit comments