Problem creating docs when importing sqlalchemy

Andrew Cooper avatarAndrew Cooper created an issue

This may or may not be a sphinx issue I'm running sqlalchemy 0.8 and I know the docs for that project were created using sphinx 1.1.3

I'm a newbie to sphinx. I created a new project using quickstart Then also created the rst's using sphinx-apidoc

ran the make and got ...

[Andy@bagend sphinx]$ cat  /tmp/sphinx-err-tXJH98.log
# Sphinx version: 1.2b1
# Python version: 2.6.5
# Docutils version: 0.11 release
# Jinja2 version: 2.7.1
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/cmdline.py", line 247, in main
    app.build(force_all, filenames)
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/application.py", line 211, in build
    self.builder.build_update()
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/builders/__init__.py", line 211, in build_update
    'out of date' % len(to_build))
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/builders/__init__.py", line 231, in build
    purple, length):
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/builders/__init__.py", line 131, in status_iterator
    for item in iterable:
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/environment.py", line 458, in update_generator
    self.read_doc(docname, app=app)
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/environment.py", line 606, in read_doc
    pub.publish()
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/core.py", line 217, in publish
    self.settings)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/readers/__init__.py", line 72, in read
    self.parse()
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/__init__.py", line 172, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 170, in run
    input_source=document['source'])
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 2726, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 2299, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 2311, in explicit_construct
    return method(self, expmatch)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 2054, in directive
    directive_class, match, type_name, option_presets)
  File "/usr/local/lib/python2.6/site-packages/docutils-0.11-py2.6.egg/docutils/parsers/rst/states.py", line 2103, in run_directive
    result = directive_instance.run()
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/ext/autodoc.py", line 1346, in run
    documenter.generate(more_content=self.content)
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/ext/autodoc.py", line 755, in generate
    self.document_members(all_members)
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/ext/autodoc.py", line 679, in document_members
    check_module=members_check_module and not isattr)
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/ext/autodoc.py", line 755, in generate
    self.document_members(all_members)
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/ext/autodoc.py", line 1087, in document_members
    ModuleLevelDocumenter.document_members(self, all_members)
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/ext/autodoc.py", line 648, in document_members
    for (mname, member, isattr) in self.filter_members(members, want_all):
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/ext/autodoc.py", line 616, in filter_members
    not keep, self.options)
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/application.py", line 357, in emit_firstresult
    for result in self.emit(event, *args):
  File "/usr/local/lib/python2.6/site-packages/Sphinx-1.2b1-py2.6.egg/sphinx/application.py", line 349, in emit
    self.debug2('[app] emitting event: %r%s', event, repr(args)[:100])
  File "build/bdist.linux-i686/egg/sqlalchemy/schema.py", line 496, in __repr__
    [repr(x) for x in self.columns] +
  File "build/bdist.linux-i686/egg/sqlalchemy/schema.py", line 1031, in __repr__
    self.table.description or "table=None")] +
  File "build/bdist.linux-i686/egg/sqlalchemy/schema.py", line 1306, in __repr__
    return "ForeignKey(%r)" % self._get_colspec()
  File "build/bdist.linux-i686/egg/sqlalchemy/schema.py", line 1356, in _get_colspec
    return "%s.%s" % (_column.table.fullname, _column.key)
AttributeError: 'Alias' object has no attribute 'fullname'

Comments (7)

  1. Mike Bayer

    not following fully but it seems like some logging in Sphinx is being handed a completed SQLAlchemy object (which is the part that does not seem normal?) which itself is not prepared to be called under __repr__().

    what is the .rst source that produces this ?

  2. Andrew Cooper
    class Biz(Base):
      __tablename__ = 'biz'
      id = Column(BigInteger, primary_key=True)
      name =  Column(String(64))
      birthstamp =  Column(DateTime, default=datetime.now)
      description =  Column(String(255))
    
    Supplier = aliased(Biz)
    
    class Rollup(Base):
      __tablename__ = 'rollup'
      id = Column(BigInteger, primary_key=True,)
      testdate =  Column(DateTime, default=datetime.now)
    
      bizID = Column(BigInteger,ForeignKey(Biz.id))
      biz = relationship("Biz", foreign_keys=[bizID])
    
      supplierID = Column(BigInteger,ForeignKey(Supplier.id))
    

    I've tracked it down to the use of aliased() and it falls over whenthe alais is used comment out the above supplierID line and its OK

    The RST for this file is

    MyDB Module
    =================
    
    .. automodule:: MyDB
        :members:
        :undoc-members:
        :show-inheritance:
    

    Hope this helps

    Andy

  3. Mike Bayer

    OK, well the mapping is wrong - it doesnt make any sense to say ForeignKey(Supplier.id) when Supplier is an aliased construct. change that to be Biz.id or better yet the string "biz.id".

  4. Georg Brandl

    That said, I'll guard this debug2() call, as it is not very helpful for Sphinx users to get exceptions coming from completely unrelated code bugs.

  5. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.