sphinx-notes / any

Sphinx domain for documenting anything
https://sphinx.silverrainz.me/any/
BSD 3-Clause "New" or "Revised" License
7 stars 0 forks source link

Panic in `note_explicit_target` #18

Closed SilverRainZ closed 2 years ago

SilverRainZ commented 2 years ago
# Sphinx version: 5.0.1
# Python version: 3.10.5 (CPython)
# Docutils version: 0.18.1 release
# Jinja2 version: 3.1.1
# Last messages:
#   [any] exclusive srcdir: /home/la/documents/bullet/_any
#   [any] exclusive outdir: /home/la/documents/bullet/_build/_any
#   构建 [mo]: 0 个 po 文件的目标文件已过期
#   构建 [html]: 165 个源文件的目标文件已过期
#   更新环境:
#   [新配置]
#   已添加 165,0 已更改,0 已移除
#   阅读源... [  0%] about/enemy
#   阅读源... [  1%] about/friends
#   阅读源... [  1%] about/me
# Loaded extensions:
#   sphinx.ext.mathjax (5.0.1) from /usr/lib/python3.10/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /usr/lib/python3.10/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /usr/lib/python3.10/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from /usr/lib/python3.10/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from /usr/lib/python3.10/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /usr/lib/python3.10/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /usr/lib/python3.10/site-packages/alabaster/__init__.py
#   sphinx.ext.graphviz (5.0.1) from /usr/lib/python3.10/site-packages/sphinx/ext/graphviz.py
#   sphinxcontrib.email (0.3.5) from /home/la/.local/lib/python3.10/site-packages/sphinxcontrib/email/__init__.py
#   sphinx.ext.githubpages (5.0.1) from /usr/lib/python3.10/site-packages/sphinx/ext/githubpages.py
#   sphinxnotes.strike (1.0) from /home/la/.local/lib/python3.10/site-packages/sphinxnotes/strike/__init__.py
#   sphinxcontrib.plantuml (unknown version) from /home/la/.local/lib/python3.10/site-packages/sphinxcontrib/plantuml.py
#   sphinxcontrib.asciinema (0.3.3) from /home/la/.local/lib/python3.10/site-packages/sphinxcontrib/asciinema/__init__.py
#   sphinxnotes.mock (1.0.0b0) from /home/la/.local/lib/python3.10/site-packages/sphinxnotes/mock/__init__.py
#   sphinx.ext.todo (5.0.1) from /usr/lib/python3.10/site-packages/sphinx/ext/todo.py
#   sphinx.ext.extlinks (5.0.1) from /usr/lib/python3.10/site-packages/sphinx/ext/extlinks.py
#   sphinxnotes.any (2.3) from /home/la/.local/lib/python3.10/site-packages/sphinxnotes/any/__init__.py
#   ablog (0.10.25) from /home/la/.local/lib/python3.10/site-packages/ablog/__init__.py
#   sphinxnotes.snippet.ext (unknown version) from /home/la/.local/lib/python3.10/site-packages/sphinxnotes/snippet/ext.py
#   sphinx_design (0.0.13) from /home/la/.local/lib/python3.10/site-packages/sphinx_design/__init__.py
#   sphinx.ext.intersphinx (5.0.1) from /usr/lib/python3.10/site-packages/sphinx/ext/intersphinx.py
#   sphinxnotes.lilypond (unknown version) from /home/la/.local/lib/python3.10/site-packages/sphinxnotes/lilypond/__init__.py
#   sphinx_book_theme (unknown version) from /home/la/.local/lib/python3.10/site-packages/sphinx_book_theme/__init__.py
#   pydata_sphinx_theme (unknown version) from /home/la/.local/lib/python3.10/site-packages/pydata_sphinx_theme/__init__.py
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app.build(args.force_all, filenames)
  File "/usr/lib/python3.10/site-packages/sphinx/application.py", line 329, in build
    self.builder.build_update()
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 288, in build_update
    self.build(to_build,
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 302, in build
    updated_docnames = set(self.read())
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 409, in read
    self._read_serial(docnames)
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 430, in _read_serial
    self.read_doc(docname)
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 483, in read_doc
    publisher.publish()
  File "/usr/lib/python3.10/site-packages/docutils/core.py", line 217, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/usr/lib/python3.10/site-packages/sphinx/io.py", line 103, in read
    self.parse()
  File "/usr/lib/python3.10/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/usr/lib/python3.10/site-packages/sphinx/parsers.py", line 78, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 170, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 240, in run
    context, next_state, result = self.check_line(
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 452, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 3018, in text
    self.section(title.lstrip(), source, style, lineno + 1, messages)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 393, in new_subsection
    newabsoffset = self.nested_parse(
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 240, in run
    context, next_state, result = self.check_line(
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 452, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2352, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2364, in explicit_construct
    return method(self, expmatch)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2101, in directive
    return self.run_directive(
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2151, in run_directive
    result = directive_instance.run()
  File "/usr/lib/python3.10/site-packages/sphinx/domains/__init__.py", line 281, in run
    return super().run()
  File "/home/la/.local/lib/python3.10/site-packages/sphinxnotes/any/directives.py", line 181, in run
    return self._run_section(obj)
  File "/home/la/.local/lib/python3.10/site-packages/sphinxnotes/any/directives.py", line 147, in _run_section
    self._setup_nodes(obj, sectnode, sectnode, sectnode)
  File "/home/la/.local/lib/python3.10/site-packages/sphinxnotes/any/directives.py", line 119, in _setup_nodes
    self.state.document.note_explicit_target(ahrnode)
  File "/usr/lib/python3.10/site-packages/docutils/nodes.py", line 1524, in note_explicit_target
    self.set_name_id_map(target, id, msgnode, explicit=True)
  File "/usr/lib/python3.10/site-packages/docutils/nodes.py", line 1466, in set_name_id_map
    self.set_duplicate_name_id(node, id, name, msgnode, explicit)
  File "/usr/lib/python3.10/site-packages/docutils/nodes.py", line 1495, in set_duplicate_name_id
    dupname(node, name)
  File "/usr/lib/python3.10/site-packages/docutils/nodes.py", line 2328, in dupname
    node['names'].remove(name)
ValueError: list.remove(x): x not in list
SilverRainZ commented 2 years ago

In _setup_nodes, the anchor node(ahrnode) will be noted by note_explicit_target for ahrnode, while sectnode is already noted by note_implicit_target. Multiple note_xxx_target calls to same node causes undefined behavior, so we use titlenode as anchor node.