Skip to content

Commit aa66411

Browse files
authored
Merge pull request #40 from SilverRainZ/anydomain3
Migrate to any domain 3.0
2 parents d79af13 + 5963b0b commit aa66411

26 files changed

Lines changed: 317 additions & 294 deletions

File tree

conf.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
# -- Split configurations ----------------------------------------------------
2121

22-
from confs.schemas import _schemas
22+
from confs.schemas import OBJECT_TYPES as _OBJECT_TYPES
2323
from confs.deploy import Deployment
2424

2525
_D = Deployment.current()
@@ -94,8 +94,12 @@
9494
keep_warnings = True
9595

9696
# A list of warning codes to suppress arbitrary warning messages.
97+
suppress_warnings = [
98+
'misc.highlighting_failure' # pygment highlight error
99+
]
100+
97101
if _D is _D.Local:
98-
suppress_warnings = ['ref.' + x.objtype for x in _schemas]
102+
suppress_warnings.extend(['ref.' + x for x in _OBJECT_TYPES])
99103

100104
# Auto numbered figures, tables and code-blocks if they have a caption.
101105
# numfig = True
@@ -223,7 +227,8 @@
223227
}
224228

225229
extensions.append('sphinxnotes.any')
226-
any_schemas = _schemas
230+
any_domain_name = 'any'
231+
any_object_types = _OBJECT_TYPES
227232

228233
extensions.append('ablog')
229234
blog_path = 'blog'
@@ -370,13 +375,12 @@
370375

371376
extensions.append('sphinxnotes.poc')
372377

378+
extensions.append('sphinxnotes.data')
379+
373380
def setup(app):
374-
# Dump any domain data:
375-
# from conf.dump_any_domain import setup
376-
# setup(app)
377-
# Query artworks from LATree.
378381

379382
from confs import fetch_artwork
380-
fetch_artwork.setup(app)
383+
384+
fetch_artwork.setup(app) # query artworks from LATree
381385

382386
...

confs/fetch_artwork.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from sphinx.application import Sphinx
66
from sphinx.environment import BuildEnvironment
77
from sphinx.util import logging
8-
from sphinxnotes.any.template import Environment as TemplateEnvironment
8+
from sphinxnotes.data.render.template import _JinjaEnv
99

1010
from .deploy import Deployment
1111

@@ -24,14 +24,22 @@ def _filter(id_: str) -> str | None:
2424
imgdir = env.srcdir.joinpath(imgdir)
2525
if Deployment.current() == Deployment.Local:
2626
try:
27-
subprocess.run(['/home/la/sync/latree/bin/artworks', 'fetch', id_, imgdir])
27+
result = subprocess.run(['/home/la/sync/latree/bin/artworks', 'fetch', id_, imgdir])
2828
except Exception as e:
29-
logger.warning('failed to fetch artwork: %s', e)
29+
errmsg = str(e)
30+
else:
31+
if result.returncode == 0:
32+
errmsg = None
33+
else:
34+
errmsg = f'error code: {result.returncode}'
35+
if errmsg:
36+
logger.warning(f'failed to fetch arwork by ID {id_}: {errmsg}')
37+
3038
f = f'/{imgdir}/{id_}.webp'
3139
return f if path.exists(f) else None
3240

3341
return _filter
3442

3543

3644
def setup(app: Sphinx):
37-
TemplateEnvironment.add_filter('fetch_artwork', fetch_artwork_filter)
45+
_JinjaEnv.add_filter('fetch_artwork', fetch_artwork_filter)

0 commit comments

Comments
 (0)