lepture / shibuya

A responsive, good looking with modern design documentation theme for Sphinx, with great supports for many sphinx extensions.
https://shibuya.lepture.com
BSD 3-Clause "New" or "Revised" License
176 stars 5 forks source link

UnboundLocalError with Sphinx AutoAPI on Windows #37

Closed vivekjoshy closed 6 months ago

vivekjoshy commented 6 months ago

Unable to build the docs, using make.bat html. Gives the following error:

(3.12) PS C:\Users\taven\PycharmProjects\openskill.py\docs> .\make.bat html -v
Running Sphinx v7.2.6
checking bibtex cache... out of date
parsing bibtex file C:\Users\taven\PycharmProjects\openskill.py\docs\source\references.bib... parsed 2 entries
[autosummary] generating autosummary for: api/openskill/index.rst, api/openskill/models/common/index.rst, api/openskill/models/index.rst, api/openskill/models/weng_lin/bradley_terry_full/index.rst, api/openskill/models/weng_lin/bradley_terry_part/index.rst, api/openskill/models/weng_lin/common/index.rst, api/openskill/models/weng_lin/index.rst, api/openskill/models/weng_lin/plackett_luce/index.rst, api/openskill/models/weng_lin/thurstone_mosteller_full/index.rst, api/openskill/models/weng_lin/thurstone_mosteller_part/index.rst, ..., contributing.rst, contributors.rst, faq.rst, index.rst, installation.rst, internals.rst, license.rst, manual.rst, ordinal.ipynb, references.rst
loading intersphinx inventory from https://docs.python.org/3/objects.inv...
loading intersphinx inventory from https://www.sphinx-doc.org/en/master/objects.inv...
[AutoAPI] Reading files... [100%] C:\Users\taven\PycharmProjects\openskill.py\openskill\models\weng_lin\__init__.py
[AutoAPI] Mapping Data... [100%] C:\Users\taven\PycharmProjects\openskill.py\openskill\models\weng_lin\__init__.py
[AutoAPI] Rendering Data... [ 10%] openskill
[AutoAPI] Rendering Data... [ 20%] openskill.models.common
[AutoAPI] Rendering Data... [ 30%] openskill.models
[AutoAPI] Rendering Data... [ 40%] openskill.models.weng_lin.bradley_terry_full
[AutoAPI] Rendering Data... [ 50%] openskill.models.weng_lin.bradley_terry_part
[AutoAPI] Rendering Data... [ 60%] openskill.models.weng_lin.common
[AutoAPI] Rendering Data... [ 70%] openskill.models.weng_lin.plackett_luce
[AutoAPI] Rendering Data... [ 80%] openskill.models.weng_lin.thurstone_mosteller_full
[AutoAPI] Rendering Data... [ 90%] openskill.models.weng_lin.thurstone_mosteller_part
[AutoAPI] Rendering Data... [100%] openskill.models.weng_lin

myst v2.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=set(), disable_syntax=[], all_links_external=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 21 source files that are out of date
updating environment: [new config] 21 added, 0 changed, 0 removed
reading sources... [100%] references
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets... copying static files... done
copying extra files... done
done
writing output... [  5%] api/openskill/index
Theme error:
An error happened in rendering the page api/openskill/index.
Reason: UnboundLocalError("cannot access local variable 'url' where it is not associated with a value")
vivekjoshy commented 6 months ago

Documenting here in case anyone else comes across this issue. I've tracked it down to these lines of code:

https://github.com/lepture/shibuya/blob/9ca4b606060a4eb9a6b9ed438b76ce8bd2040aa8/src/shibuya/context.py#L64-L71

The error was being caused by a typo in the source_type for html_context. I put github|gitlab instead of github. Would be nice if the error was explicit.

lepture commented 6 months ago

fixed https://github.com/lepture/shibuya/commit/2ac12a1d749453ccc4f84084a4899a30d385cbc8