make html すると UndefinedError が発生



layout.html 内に pathto と書こうとして path と書いていました。 そのためテンプレート内に間違った記述があるとして UndefinedError が発生していました。 layout.html 内の pathpathto に修正しました。


自作のテーマ oldschool を作成中に make html すると UndefinedError が発生するようになりました。

$ make html
Running Sphinx v1.1.3
loading translations [ja]... done
loading pickled environment... done
building [html]: targets for 4 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
preparing documents... done
writing output... [ 25%] index

Exception occurred:
  File "/usr/opt/lib/python27/site-packages/jinja2/", line 276, in is
    return not (getattr(obj, 'unsafe_callable', False) or
UndefinedError: 'path' is undefined
The full traceback has been saved in /tmp/sphinx-err-onllzv.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message c
an be provided next time.
Either send bugs to the mailing list at <
or report them in the tracker at <
>. Thanks!


$ cat /tmp/sphinx-err-onllzv.log
# Sphinx version: 1.1.3
# Python version: 2.7.3
# Docutils version: 0.10 release
# Jinja2 version: 2.6
Traceback (most recent call last):
  File "/usr/lib/python27/site-packages/sphinx/", line 189, in main, filenames)
  File "/usr/lib/python27/site-packages/sphinx/", line 204, in build
  File "/usr/lib/python27/site-packages/sphinx/builders/", line 196, in build_update
    'out of date' % len(to_build))
  File "/usr/lib/python27/site-packages/sphinx/builders/", line 252, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/lib/python27/site-packages/sphinx/builders/", line 292, in write
    self.write_doc(docname, doctree)
  File "/usr/lib/python27/site-packages/sphinx/builders/", line 426, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/usr/lib/python27/site-packages/sphinx/builders/", line 728, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/usr/lib/python27/site-packages/sphinx/", line 128, in render
    return self.environment.get_template(template).render(context)
  File "D:/ng/opt/python27/lib/site-packages/jinja2/", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python27/site-packages/sphinx/themes/basic/page.html", line 10, in top-level template code
    {% extends "layout.html" %}
  File "D:/ng/home/sximadaw3/_theme/oldschool/layout.html", line 11, in top-level template code
    {% extends "agogo/layout.html" %}
  File "/usr/lib/python27/site-packages/sphinx/themes/agogo/layout.html", line 11, in top-level template code
    {% extends "basic/layout.html" %}
  File "/usr/lib/python27/site-packages/sphinx/themes/basic/layout.html", line 156, in top-level template code
    {%- block header %}{% endblock %}
  File "/home/sximadaw3/_theme/oldschool/layout.html", line 19, in block "header"
    <li><a href="{{ path('work/index') }}">WORK</li>
  File "D:/ng/opt/python27/lib/site-packages/jinja2/", line 347, in call
    if not __self.is_safe_callable(__obj):
  File "D:/ng/opt/python27/lib/site-packages/jinja2/", line 276, in is_safe_callable
    return not (getattr(obj, 'unsafe_callable', False) or
UndefinedError: 'path' is undefined

テンプレートのエラーのようです。 layout.html 内の次の行がダメみたいです。

<li><a href="{{ path('work/index') }}">WORK</li>

!? これははおかしいですね。:

{{ path('work/index') }}


{{ pathto('work/index') }}







inserted by FC2 system