sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.41k stars 2.09k forks source link

Exception when calling the astext() method in docutils nodes.py. #4024

Closed albert2126 closed 7 years ago

albert2126 commented 7 years ago

Subject:

Problem

sphinx-build -t debug -T -q -W -b dirhtml -D release="2.0-rUnversioned directory" -D html_last_updated_fmt="%d-%b-%Y" -w _build/debug/html.log -d _build/debug/doctrees . _build/debug/html

sphinx-err-10t9lp.txt

Procedure to reproduce the problem

sphinx-build -t debug -T -q -W -b dirhtml -D release="2.0-rUnversioned directory" -D html_last_updated_fmt="%d-%b-%Y" -w _build/debug/html.log -d _build/debug/doctrees . _build/debug/html

Error logs / results

<Paste your error log here>
Exception occurred:
  File "/usr/lib/python2.7/site-packages/docutils/nodes.py", line 620, in astext
    [child.astext() for child in self.children])
TypeError: astext() takes exactly 2 arguments (1 given)
[sphinx-err-10t9lp.txt](https://github.com/sphinx-doc/sphinx/files/1248308/sphinx-err-10t9lp.txt)

Full log:

Pasting the full error log as it was not possible to upload the log file:

# Sphinx version: 1.6.3
# Python version: 2.7.5 (CPython)
# Docutils version: 0.14 
# Jinja2 version: 2.9.6
# Last messages:
#   reading sources... [ 85%] internal/poa-dev-howto/howto-add-capability-manually
#   reading sources... [ 86%] internal/poa-integration/poa-integration
#   reading sources... [ 86%] internal/poa-security-model/poa-security-model
#   reading sources... [ 86%] internal/poa-security-model/poa-session
#   reading sources... [ 86%] internal/rest-api-guidelines
#   reading sources... [ 86%] internal/slimApp/index
#   reading sources... [ 86%] internal/sphinx-howto/aps-lexer
#   reading sources... [ 86%] internal/sphinx-howto/diagrams
#   reading sources... [ 86%] internal/sphinx-howto/general
#   reading sources... [ 86%] internal/sphinx-howto/http-domain
# Loaded extensions:
#   json-builder (unknown version) from /root/ap-doc/_plugins/json-builder.pyc
#   youtube (unknown version) from /root/ap-doc/_plugins/youtube.pyc
#   href (unknown version) from /root/ap-doc/_plugins/href.pyc
#   apsfiddle (unknown version) from /root/ap-doc/_plugins/apsfiddle.pyc
#   sphinx.ext.todo (1.6.3) from /usr/lib/python2.7/site-packages/sphinx/ext/todo.pyc
#   plugins (unknown version) from /root/ap-doc/_plugins/plugins.pyc
#   alabaster (0.7.10) from /usr/lib/python2.7/site-packages/alabaster/__init__.pyc
#   wsd (unknown version) from /root/ap-doc/_plugins/wsd.pyc
#   sphinx.ext.ifconfig (1.6.3) from /usr/lib/python2.7/site-packages/sphinx/ext/ifconfig.pyc
#   sphinx_http_domain (unknown version) from /root/ap-doc/_plugins/sphinx_http_domain/__init__.pyc
#   iframe (unknown version) from /root/ap-doc/_plugins/iframe.pyc
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/sphinx/cmdline.py", line 306, in main
    app.build(opts.force_all, filenames)
  File "/usr/lib/python2.7/site-packages/sphinx/application.py", line 339, in build
    self.builder.build_update()
  File "/usr/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 331, in build_update
    'out of date' % len(to_build))
  File "/usr/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 344, in build
    updated_docnames = set(self.env.update(self.config, self.srcdir, self.doctreedir))
  File "/usr/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 583, in update
    self._read_serial(docnames, self.app)
  File "/usr/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 602, in _read_serial
    self.read_doc(docname, app)
  File "/usr/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 723, in read_doc
    pub.publish()
  File "/usr/lib/python2.7/site-packages/docutils/core.py", line 218, in publish
    self.apply_transforms()
  File "/usr/lib/python2.7/site-packages/docutils/core.py", line 199, in apply_transforms
    self.document.transformer.apply_transforms()
  File "/usr/lib/python2.7/site-packages/docutils/transforms/__init__.py", line 171, in apply_transforms
    transform.apply(**kwargs)
  File "/usr/lib/python2.7/site-packages/sphinx/transforms/__init__.py", line 242, in apply
    apply_source_workaround(n)
  File "/usr/lib/python2.7/site-packages/sphinx/util/nodes.py", line 61, in apply_source_workaround
    node.rawsource = node.astext()
  File "/usr/lib/python2.7/site-packages/docutils/nodes.py", line 620, in astext
    [child.astext() for child in self.children])
  File "/usr/lib/python2.7/site-packages/docutils/nodes.py", line 620, in astext
    [child.astext() for child in self.children])
TypeError: astext() takes exactly 2 arguments (1 given)

Expected results

### Reproducible project / your project - ### Environment info - OS: - Python version: 2.7.5 - Sphinx version: 1.6.3 - I've found the astext() method is redefined in the sphinx_http_domain extension. It requires 2 arguments: def astext(self, node): return (self.wrapper[0] + nodes.TextElement.astext(node) + self.wrapper[1]) Do I have to replace it?
albert2126 commented 7 years ago

I tried the Doc build process in various versions of Sphinx and noticed that the error appears starting with Sphinx-1.3.2.

albert2126 commented 7 years ago

Fixed by replacing the old sphinx_http_domain extension with the new.

  1. Install the new sphinx extension:

    pip install sphinxcontrib.httpdomain

  2. In conf.py, replace the old extension with the new one, i.e. in the extentions[] list, replace 'sphinx_http_domain' with 'sphinxcontrib.httpdomain'.