生成Sphinx文档时出现“未知C全局变量”错误

时间:2013-10-25 13:13:28

标签: python swig python-sphinx

我正在使用Sphinx为python项目生成文档。我有大约6种不同的包装;其中5个工作正常但每当我尝试生成第6个文档时,我收到以下错误消息:

Exception occurred:
  File "/usr/local/lib/python3.3/site-packages/sphinx/ext/autodoc.py", line 1066, in can_document_member
    return isinstance(member, class_types) and \
NameError: Unknown C global variable

Sphinx错误日志:

# Sphinx version: 1.1.3
# Python version: 3.3.2
# Docutils version: 0.11 release
# Jinja2 version: 2.7.1
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/site-packages/sphinx/cmdline.py", line 189, in main
    app.build(force_all, filenames)
  File "/usr/local/lib/python3.3/site-packages/sphinx/application.py", line 204, in build
    self.builder.build_update()
  File "/usr/local/lib/python3.3/site-packages/sphinx/builders/__init__.py", line 196, in build_update
    'out of date' % len(to_build))
  File "/usr/local/lib/python3.3/site-packages/sphinx/builders/__init__.py", line 216, in build
    purple, length):
  File "/usr/local/lib/python3.3/site-packages/sphinx/builders/__init__.py", line 120, in status_iterator
    for item in iterable:
  File "/usr/local/lib/python3.3/site-packages/sphinx/environment.py", line 613, in update_generator
    self.read_doc(docname, app=app)
  File "/usr/local/lib/python3.3/site-packages/sphinx/environment.py", line 761, in read_doc
    pub.publish()
  File "/usr/local/lib/python3.3/site-packages/docutils/core.py", line 217, in publish
    self.settings)
  File "/usr/local/lib/python3.3/site-packages/docutils/readers/__init__.py", line 72, in read
    self.parse()
  File "/usr/local/lib/python3.3/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/__init__.py", line 172, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 170, in run
    input_source=document['source'])
  File "/usr/local/lib/python3.3/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/local/lib/python3.3/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 2726, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python3.3/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/local/lib/python3.3/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 2726, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python3.3/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/local/lib/python3.3/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 2299, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 2311, in explicit_construct
    return method(self, expmatch)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 2054, in directive
    directive_class, match, type_name, option_presets)
  File "/usr/local/lib/python3.3/site-packages/docutils/parsers/rst/states.py", line 2103, in run_directive
    result = directive_instance.run()
  File "/usr/local/lib/python3.3/site-packages/sphinx/ext/autodoc.py", line 1303, in run
    documenter.generate(more_content=self.content)
  File "/usr/local/lib/python3.3/site-packages/sphinx/ext/autodoc.py", line 734, in generate
    self.document_members(all_members)
  File "/usr/local/lib/python3.3/site-packages/sphinx/ext/autodoc.py", line 629, in document_members
    classes = [cls for cls in AutoDirective._registry.values()
  File "/usr/local/lib/python3.3/site-packages/sphinx/ext/autodoc.py", line 630, in <listcomp>
    if cls.can_document_member(member, mname, isattr, self)]
  File "/usr/local/lib/python3.3/site-packages/sphinx/ext/autodoc.py", line 1066, in can_document_member
    return isinstance(member, class_types) and \
NameError: Unknown C global variable

我看不出一个有问题的包和那些工作正常的包之间有任何明显的区别,并且Sphinx错误似乎没有指出我的东西的任何特定问题部分。有人知道是什么原因引起的吗?

更新  下面的mzjn似乎打了它,但错误有点令人费解。我正在使用SWIG,并且出于某种原因,来自其他模块的通配符导入语句,即

from foo import *
当foo从SWIG生成的模块导入某些内容时,

导致Sphinx崩溃。但是,如果我通过并替换特定的import语句

from foo import bar

其中bar是我真正需要来自foo的类,然后一切正常。

0 个答案:

没有答案