Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error in type declaration" without any type specified. #1003

Open
vollous opened this issue Dec 12, 2024 · 3 comments
Open

"Error in type declaration" without any type specified. #1003

vollous opened this issue Dec 12, 2024 · 3 comments

Comments

@vollous
Copy link

vollous commented Dec 12, 2024

I am getting this error which is not very specific about what is happening:

/Users/joaofranciscoviana/mega/BSMPT/docs/index.rst:18: WARNING: Error in type declaration.
(...)  
  Running directive: .. cpp:function::  bool DoGlobMinOverlap (const Phase &new_phase, const Phase &old_phase)
  Running directive: .. cpp:function::  void MultiStepPTMode2 (const std::vector< double > &LowTempPoint, const std::vector< double > &HighTempPoint)
  Running directive: .. cpp:function::  void PrintPhasesDiagram (int size=100)
Running directive: .. cpp:type:: 

If typedef-like declaration:
  Type must be either just a name or a typedef-like declaration.
  If just a name:
    Error in declarator or parameters-and-qualifiers
    Invalid C++ declaration: Expected identifier in nested name. [error at 0]
      
      ^
  If typedef-like declaration:
    Invalid C++ declaration: Expected identifier in nested name. [error at 0]
      
      ^
If type alias or template alias:
  Invalid C++ declaration: Expected identifier in nested name. [error at 0]
    
    ^


Exception occurred:
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/renderer/sphinxrenderer.py", line 714, in handle_declaration
    assert isinstance(n, addnodes.desc_sig_keyword)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
The full traceback has been saved in /var/folders/b0/82xdpcfx74ng4080p8zb5d780000gn/T/sphinx-err-ri20kvg4.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 can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
make: *** [html] Error 2

The log file is

# Platform:         darwin; (macOS-15.1.1-arm64-arm-64bit)
# Sphinx version:   8.1.3
# Python version:   3.12.7 (CPython)
# Docutils version: 0.21.2
# Jinja2 version:   3.1.4
# Pygments version: 2.18.0

# Last messages:
#   writing output...
#   
#   building [html]: targets for 1 source files that are out of date
#   updating environment:
#   [new config]
#   1 added, 0 changed, 0 removed
#   
#   reading sources... [100%]
#   index
#   

# Loaded extensions:
#   sphinx.ext.mathjax (8.1.3)
#   alabaster (1.0.0)
#   sphinxcontrib.applehelp (2.0.0)
#   sphinxcontrib.devhelp (2.0.0)
#   sphinxcontrib.htmlhelp (2.1.0)
#   sphinxcontrib.serializinghtml (2.0.0)
#   sphinxcontrib.qthelp (2.0.0)
#   breathe (4.35.0)

# Traceback:
Traceback (most recent call last):
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/sphinx/cmd/build.py", line 514, in build_main
    app.build(args.force_all, args.filenames)
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/sphinx/application.py", line 381, in build
    self.builder.build_update()
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 358, in build_update
    self.build(
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 385, in build
    updated_docnames = set(self.read())
                           ^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 502, in read
    self._read_serial(docnames)
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 567, in _read_serial
    self.read_doc(docname)
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 630, in read_doc
    publisher.publish()
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/core.py", line 234, in publish
    self.document = self.reader.read(self.source, self.parser,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/sphinx/io.py", line 106, in read
    self.parse()
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/sphinx/parsers.py", line 85, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 169, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2790, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
                   ^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2359, in explicit_markup
    self.explicit_list(blank_finish)
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2384, in explicit_list
    newline_offset, blank_finish = self.nested_list_parse(
                                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 316, in nested_list_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2662, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2369, in explicit_construct
    return method(self, expmatch)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2106, in directive
    return self.run_directive(
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2156, in run_directive
    result = directive_instance.run()
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/directives/index.py", line 88, in run
    return self.handle_contents(project_info)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/directives/index.py", line 56, in handle_contents
    node_list = object_renderer.render(context.node_stack[0], context)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/renderer/sphinxrenderer.py", line 2628, in render
    result = method(self, node)
             ^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/renderer/sphinxrenderer.py", line 1008, in visit_doxygen
    nodelist.extend(self.render(n))
                    ^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/renderer/sphinxrenderer.py", line 2628, in render
    result = method(self, node)
             ^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/renderer/sphinxrenderer.py", line 2508, in dispatch_compound
    return self.visit_compound(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/renderer/sphinxrenderer.py", line 1162, in visit_compound
    return self.visit_namespace(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/renderer/sphinxrenderer.py", line 1138, in visit_namespace
    nodes = self.handle_declaration(
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joaofranciscoviana/miniconda3/lib/python3.12/site-packages/breathe/renderer/sphinxrenderer.py", line 714, in handle_declaration
    assert isinstance(n, addnodes.desc_sig_keyword)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

I took a closer look at the assertion that raises the error isinstance(n, addnodes.desc_sig_keyword), its arguments are

declarator = <desc_signature _toc_name="PhonyNameDueToError" _toc_parts="('PhonyNameDueToError',)" classes="sig sig-object" multi_line_parameter_list="False"><desc_name classes="['sig-name', 'descname']" xml:space="preserve"/></desc_signature>
display_obj_type = namespace
n = <desc_name classes="['sig-name', 'descname']" xml:space="preserve"/>
addnodes.desc_sig_keyword = <class 'sphinx.addnodes.desc_sig_keyword'>

Am I missing something?

@jbrd
Copy link

jbrd commented Dec 14, 2024

I am also experiencing this - although I was only able to repro it when I upgraded Doxygen to 1.12.0. I was previously on 1.9.2 and didn't get this issue.

It seems to be caused by a namespace XML file (in my case namespace_0d2.xml that contains the following:

<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.12.0" xml:lang="en-US">
  <compounddef id="namespace_0d2" kind="namespace" language="C++">
    <compoundname></compoundname>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
    </detaileddescription>
    <location file="Private/ParseBVH.cpp" line="13" column="1"/>
  </compounddef>
</doxygen>

Removing the corresponding entry from index.xml fixes the issue:

  <compound refid="namespace_0d2" kind="namespace"><name>@2</name>
  </compound>

@Makman2
Copy link

Makman2 commented Dec 17, 2024

Can confirm this happens with breathe v4.35.0 as well as most recent master (62695c7) with following doxygen versions:

  • 1.9.2: ✔️
  • 1.9.4: ✔️
  • 1.9.5: ✔️
  • 1.9.6: ✔️
  • 1.9.8: ❌
  • 1.12.0: ❌

So the breakage appears due to something in doxygen appearing from maybe 1.9.7, but definitely with 1.9.8.

I was able for the sake of repairing the output to replace the code here:

https://github.com/breathe-doc/breathe/blob/main/breathe/renderer/sphinxrenderer.py#L715-L716

with

                if isinstance(n, addnodes.desc_name):
                    declarator[0] = addnodes.desc_name(display_obj_type, display_obj_type)
                elif isinstance(n, addnodes.desc_sig_keyword):
                    declarator[0] = addnodes.desc_sig_keyword(display_obj_type, display_obj_type)
                else:
                    raise AssertionError(f'invalid type: {type(n)}')

and then it renders again.

However this is not necessarily (or rather likely) the correct solution as I am not really knowledgeable about breathe and Sphinx interna.

@michaeljones
Copy link
Collaborator

Thank you for the issue. We're currently working on getting this project funded and maintenance and development will continue when that is in place. Fortunately one organisation is in the process of providing some funding if it goes smoothly but we're always open to other sources to keep the project sustainable for as long as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants