breathe-doc / breathe

ReStructuredText and Sphinx bridge to Doxygen
https://breathe-doc.org
Other
756 stars 202 forks source link

Parser chokes on SFINAE construct in 4.26.1 #624

Open paulgessinger opened 3 years ago

paulgessinger commented 3 years ago

Hi, we're using sphinx+breathe for our project at acts-project/acts, acts.readthedocs.org.

With the recent changes in 4.26.1 we get an exception during our doc build, where the parser seems to choke on something that was fine before. Here's an excerpt from our log:

/__w/acts/acts/docs/api/function_namespace_acts_1a8cac9e2dd1d569616ca040fae2755ff3.rst:13: WARNING: doxygenfunction: Unable to resolve function "Acts::globalToLocalFromBin" with arguments (Acts::BinningValue&) in doxygen xml output for project "Acts" from directory: _build/doxygen-xml.
Potential matches:
- std::function<double(Acts::Vector3)> globalToLocalFromBin(Acts::BinningValue &type)

Exception occurred:
  File "/usr/local/lib/python3.8/dist-packages/sphinx/domains/cpp.py", line 5994, in _parse_declarator
    raise self._make_multi_error(prevErrors, header) from exNoPtrParen
sphinx.util.cfamily.DefinitionError: Error in declarator
If declarator-id with parameters-and-qualifiers:
  Invalid C++ declaration: Expecting "," or ")" in parameters-and-qualifiers, got ".". [error at 41]
    (Callable<N>::invoke(std::declval<Args>()...)) template_switch(size_t v, Args&&... args)
    -----------------------------------------^
If parenthesis in noptr-declarator:
  Error in declarator or parameters-and-qualifiers
  If pointer to member declarator:
    Invalid C++ declaration: Expected '::' in pointer to member (function). [error at 39]
      (Callable<N>::invoke(std::declval<Args>()...)) template_switch(size_t v, Args&&... args)
      ---------------------------------------^
  If declarator-id:
    Invalid C++ declaration: Unexpected ':' after identifier. [error at 24]
      (Callable<N>::invoke(std::declval<Args>()...)) template_switch(size_t v, Args&&... args)
      ------------------------^
The full traceback has been saved in /tmp/sphinx-err-eds0c1fg.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!
ninja: build stopped: subcommand failed.
Error: Process completed with exit code 1.

The code it appears to choke on is the SFINAE construct here, which seems valid to me.

I can probably try to rewrite our code so it doesn't break the parser, but I wanted to ask if this rings any bells first.

jakobandersen commented 3 years ago

Can you make the full traceback available? and potentially a minimal example that reproduces the problem? It looks quite similar to #611, in that something is going wrong with a decltype. Doxygen/Breathe does not send the correct full declaration to Sphinx, which rightfully rejects it. From a very brief try to reproduce it (unsuccessfully) the Doxygen XML looks reasonable. In any case, Breathe should probably have an extra try-block somewhere that catches these kinds of cases, and converts the parsing error into a warning.

paulgessinger commented 3 years ago

The full traceback is here: https://github.com/acts-project/acts/runs/1740565809

It does look very similar, you're right. Getting a minimal example is a bit complicated since our code is relatively tangled up.

Could you have a look at the traceback and see if that provides context, and if not I'll try to strip out and try to make a standalone example, ok?

jakobandersen commented 3 years ago

Sorry but the traceback is not there. It's in the described /tmp/ file. Otherwise you can invoke sphinx-build with -v, then the traceback is inlined in the console output. I did notice some other warnings/errors in the log, so if you can provide instructions on how to compile the docs from the repo I may be able to investigate locally at some point.

paulgessinger commented 3 years ago

Sorry, then I misunderstood, what you meant. Traceback is here: traceback.log. The traceback is form my local machine now, but it shows the same error as our CI does.

Thanks a ton for looking into this already! We indeed have a bunch of other warnings, which we mostly chalked up to be due to us doing a bunch of moderate to dodgy template stuff, which we assumed to be super hard to parse correctly. If you end up having a look, I'm more than happy to provide any help whatsoever!

As for building the docs, we have some instructions here.

tl;dr:

YannickJadoul commented 3 years ago

I seem to have bumped into a very similar issue (in pybind/pybind11#2828), when documenting the following function template:

template <return_value_policy Policy = return_value_policy::reference_internal,
          typename Iterator,
          typename Sentinel,
          typename ValueType = decltype(*std::declval<Iterator>()),
          typename... Extra>
iterator make_iterator(Iterator first, Sentinel last, Extra &&... extra) {

Here's the log: sphinx-err-sv5d3kwm.log

vermeeren commented 3 years ago

From https://github.com/michaeljones/breathe/issues/663#issuecomment-809351599, this might be (partially) fixed with doxygen/doxygen#8465.