-
Notifications
You must be signed in to change notification settings - Fork 28
/
conf.py
113 lines (95 loc) · 4.06 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
###############################################################################
# Auto-generated by `jupyter-book config`
# If you wish to continue using _config.yml, make edits to that file and
# re-generate this one.
###############################################################################
from datetime import date
author = 'Peter Betlem, Nil Rodes and Contributors'
bibtex_bibfiles = ['content/lessons/about/zreferences.bib']
bibtex_default_style = 'alpha'
comments_config = {'hypothesis': True, 'utterances': False}
copyright = f'{date.today().year} (CC-BY-NC except where otherwise stated)'
exclude_patterns = ['**.ipynb_checkpoints', '.DS_Store', 'Thumbs.db', '_build']
extensions = ['sphinx_togglebutton', 'sphinx_copybutton', 'myst_nb', 'jupyter_book', 'sphinx_thebe', 'sphinx_comments', 'sphinx_external_toc', 'sphinx.ext.intersphinx', 'sphinx_design', 'sphinx_book_theme', 'sphinxcontrib.bibtex', 'sphinx_jupyterbook_latex']
external_toc_exclude_missing = True
external_toc_path = '_toc.yml'
html_baseurl = ''
html_favicon = ''
html_logo = './content/assets/logo.gif'
html_sourcelink_suffix = ''
html_theme = 'sphinx_book_theme'
html_theme_options = {
'search_bar_text': 'Search this book...',
'launch_buttons': {'notebook_interface': 'classic', 'binderhub_url': '', 'jupyterhub_url': '', 'thebe': False, 'colab_url': ''},
'path_to_docs': '',
'repository_url': 'https://github.com/UNISvalbard/Geo-SfM',
'repository_branch':
'main', 'extra_footer': '',
'home_page_in_toc': True,
'announcement': 'Found this tutorial helpful? Please Star me <a href="https://github.com/UNISvalbard/Geo-SfM"> <img src="https://img.shields.io/github/stars/UNISvalbard/Geo-SfM"></a>',
'analytics': {'google_analytics_id': ''},
'use_repository_button': True,
'use_edit_page_button': True,
'use_issues_button': True}
html_title = 'Geo-SfM Course'
latex_engine = 'pdflatex'
myst_enable_extensions = ['colon_fence', 'dollarmath', 'linkify', 'substitution', 'tasklist']
myst_url_schemes = ['mailto', 'http', 'https']
nb_execution_allow_errors = False
nb_execution_cache_path = ''
nb_execution_excludepatterns = []
nb_execution_in_temp = False
nb_execution_mode = 'auto'
nb_execution_timeout = 30
nb_output_stderr = 'show'
numfig = True
pygments_style = 'sphinx'
suppress_warnings = ['myst.domains']
use_jupyterbook_latex = True
use_multitoc_numbering = True
html_extra_path = ['extra']
"""
Custom scripts
"""
import yaml
from textwrap import dedent
from pathlib import Path
from sphinx.application import Sphinx
from sphinx.util import logging
LOGGER = logging.getLogger("conf")
def build_3dmodel_gallery(app: Sphinx):
# Build the gallery file
LOGGER.info("building gallery...")
grid_items = []
models = yaml.safe_load((Path(app.srcdir) / "3dmodels-sketchfab.yml").read_text())
keyList = [2021,2022,2023,2024]
grid_items = {key: [] for key in keyList}
for item in models:
if not item.get("year"):
item["year"] = 0
grid_items[item["year"]].append(
f"""\
`````{{grid-item-card}}
:text-align: center
<iframe frameborder="0" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" allow="autoplay; fullscreen; xr-spatial-tracking" xr-spatial-tracking execution-while-out-of-viewport execution-while-not-rendered web-share src="https://sketchfab.com/models/{item["sketchfab_id"]}/embed" width=100%> </iframe>
`````
"""
)
print(grid_items)
panels = "````````{tab-set}"
for year in grid_items.keys():
if grid_items[year]:
dmodels = "\n".join(grid_items[year])
print(grid_items.keys())
panels += f"""
```````{{tab-item}} {str(year)}
``````{{grid}} 1 2 3 3
:gutter: 1 1 2 2
{dmodels}
``````
```````
"""
panels += "````````"
(Path(app.srcdir) / "3dmodels-sketchfab.txt").write_text(panels.replace(" ",""))
def setup(app: Sphinx):
app.connect("builder-inited", build_3dmodel_gallery)