ASFHyP3 / mkdocs-asf-theme

An extension of the MkDocs Material Theme for ASF
BSD 3-Clause "New" or "Revised" License
1 stars 3 forks source link

mkdocs-asf-theme build fails if no additional social feeds are configured #56

Open dgpalmieri opened 9 months ago

dgpalmieri commented 9 months ago

Attempting to build the OpenScienceLab docs fails if at least one additional social feed for the footer is not configured.

Traceback:

❯ mkdocs serve
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
             - dev.md
             - release_notes.md
             - dev-guides/system_diagram.md
             - release-notes/release_02-2023.md
Traceback (most recent call last):
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/bin/mkdocs", line 10, in <module>
    sys.exit(cli())
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/mkdocs/__main__.py", line 270, in serve_command
    serve.serve(**kwargs)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 86, in serve
    builder(config)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, live_server=None if is_clean else server, dirty=is_dirty)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/mkdocs/commands/build.py", line 340, in build
    _build_theme_template(template, env, files, config, nav)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/mkdocs/commands/build.py", line 110, in _build_theme_template
    output = _build_template(template_name, template, files, config, nav)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/mkdocs/commands/build.py", line 89, in _build_template
    output = template.render(context)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/material/templates/404.html", line 4, in top-level template code
    {% extends "main.html" %}
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/asf_theme/main.html", line 2, in top-level template code
    {% extends "base.html" %}
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/material/templates/base.html", line 202, in top-level template code
    {% block footer %}
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/material/templates/base.html", line 203, in block 'footer'
    {% include "partials/footer.html" %}
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/asf_theme/partials/footer.html", line 131, in top-level template code
    {% include "partials/social.html" %}
  File "/home/dgpalmieri/mambaforge/envs/opensarlab-docs/lib/python3.9/site-packages/asf_theme/partials/social.html", line 27, in top-level template code
    {% for social in config.theme.social + config.extra.social %}
jinja2.exceptions.UndefinedError: 'mkdocs.config.base.LegacyConfig object' has no attribute 'social'

Configuring an additional social feed in mkdocs.yaml enables the page to build as expected.

The environment I'm building in was taken directly from the hyp3-docs repo:

name: opensarlab-docs
channels:
  - conda-forge
  - nodefaults
dependencies:
  - python=3.9
  - pip
  # For documentation
  - mkdocs=1.5.3
  - mkdocs-material=9.4.2
  - requests
  - pip:
      # For documentation
      - mkdocs-asf-theme==0.3.0
      - mkdocs-redirects
      - mkdocs-section-index
      - mkdocstrings
      - mkdocstrings-python
      - mkdocs-macros-plugin
❯ pip list
Package                    Version
-------------------------- ----------
Babel                      2.14.0
Brotli                     1.1.0
certifi                    2024.2.2
charset-normalizer         3.3.2
click                      8.1.7
colorama                   0.4.6
ghp-import                 2.1.0
griffe                     0.40.0
idna                       3.6
importlib-metadata         7.0.1
Jinja2                     3.1.3
Markdown                   3.5.2
MarkupSafe                 2.1.5
mergedeep                  1.3.4
mkdocs                     1.5.3
mkdocs-asf-theme           0.3.0
mkdocs-autorefs            0.5.0
mkdocs-macros-plugin       1.0.5
mkdocs-material            9.4.2
mkdocs-material-extensions 1.3.1
mkdocs-redirects           1.2.1
mkdocs-section-index       0.3.8
mkdocstrings               0.24.0
mkdocstrings-python        1.8.0
packaging                  23.2
paginate                   0.5.6
pathspec                   0.12.1
pip                        24.0
platformdirs               4.2.0
Pygments                   2.17.2
pymdown-extensions         10.7
PySocks                    1.7.1
python-dateutil            2.8.2
pytz                       2024.1
PyYAML                     6.0.1
pyyaml_env_tag             0.1
regex                      2023.12.25
requests                   2.31.0
setuptools                 69.0.3
six                        1.16.0
termcolor                  2.4.0
typing_extensions          4.9.0
urllib3                    2.2.0
watchdog                   4.0.0
wheel                      0.42.0
zipp                       3.17.0