Handle specialized template functions#117
Conversation
diff --git a/requirements.txt b/requirements.txt
index 432ca19..90c72b3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,6 @@
bs4 # BeautifulSoup!
lxml # We need the lxml backend for BeautifulSoup.
sphinx>=1.6.1 # Exhale is a Sphinx extension. 1.6 introduces logging API.
-breathe # The directives used for documentation come from the excellent Breathe.
+# breathe # The directives used for documentation come from the excellent Breathe.
+git+https://github.com/michaeljones/breathe@refs/pull/750/merge
six # Primarily for Unicode string types
diff --git a/testing/tests/cpp_func_overloads.py b/testing/tests/cpp_func_overloads.py
index 8f55d9a..81ee6f4 100644
--- a/testing/tests/cpp_func_overloads.py
+++ b/testing/tests/cpp_func_overloads.py
@@ -93,7 +93,7 @@ class CPPFuncOverloads(ExhaleTestCase):
def test_builds(self):
"""Test deliberately kept to serve as a perpetual reminder this is still broken."""
self.app.build()
- if False: # set to True, and run: tox -e py -- -k cpp_func_overloads -s
+ if True: # set to True, and run: tox -e py -- -k cpp_func_overloads -s
import ipdb # then you can view the results
ipdb.set_trace()
print("hi there")If you apply the above patch then it will build and pause so that you can examine In order to merge this, I need to understand that change to breathe. If the change is required, then we need some kind of version switch selection in exhale. FWIW the rest of the function overload tests are still somewhat catastrophically broken and I'm not intending on fixing that anytime soon. The options reported by breathe can be explicitly hacked in and still it will not resolve. It's a very complicated issue, which you'll likely hit soon. |
|
Also, changing the diff --git a/tox.ini b/tox.ini
index 580c789..2ee0002 100644
--- a/tox.ini
+++ b/tox.ini
@@ -11,11 +11,11 @@ skip_install = true
# This way, if the variable is not set, it uses the latest version.
deps =
sphinx{env:SPHINX_VERSION:}
- breathe{env:BREATHE_VERSION:}
bs4
lxml
six
commands =
+ {envpython} -m pip install --no-build-isolation git+https://github.com/michaeljones/breathe@refs/pull/750/merge
{envpython} -m pip install -q -r requirements-dev.txt
pytest . {posargs}
{envpython} -c 'import sphinx; print("Tested against Sphinx version %s." % sphinx.__version__)' |
4474a37 to
6a3b2ce
Compare
|
Rebased and ready for a review (if CI comes out green). |
|
Thanks for reading, I'll look at this soon (as well as remove py2). Do we know what the next version of breathe will be? This requires that so I'm just going to pin |
|
I've got this slated for the weekend since it looks like I think this one fixes a number of issues with templates and believe I get to remove an obnoxious warning ❤️ Will land this ASAP, thanks again for fixing this and breathe! |
ba9aa53 to
bfe45a6
Compare
|
Sorry for the delay on this. Will be merging this since it works with the specialized pathological example you added. I keep looking at this and then desiring to fix the template overloads that are not specialized and then getting wound out over it, so unfixed they will remain with a tag to #106 and synopsis that this has to be a breathe bug but I don't think it will be easy for anyone to fix and I at least warn people in the build output. The warning from breathe: Warning doxygenfunction: Unable to resolve function “overload::blargh” with arguments (typename C::type) in doxygen xml output for project “cpp_func_overloads” from directory: ./_doxygen/xml. Potential matches: Via .. _exhale_function_overload_8hpp_1a78c463f6d2e0247e92b6a8cee2dbd86c:
Template Function overload::blargh(typename C::type)
====================================================
- Defined in :ref:`file_include_overload_overload.hpp`
Function Documentation
----------------------
.. doxygenfunction:: overload::blargh(typename C::type)So if I update .. _exhale_function_overload_8hpp_1a78c463f6d2e0247e92b6a8cee2dbd86c:
Template Function template<class C, typename T> std::enable_if<std::is_convertible<typename C::type, T>::value, T>::type overload::blargh(typename C::type)
===========================================================================================================================================================
- Defined in :ref:`file_include_overload_overload.hpp`
Function Documentation
----------------------
.. this is the one desired
.. template<class C, typename T> std::enable_if<std::is_convertible<typename C::type, T>::value, T>::type blargh(typename C::type t)
.. doxygenfunction:: template<class C, typename T> std::enable_if<std::is_convertible<typename C::type, T>::value, T>::type overload::blargh(typename C::type)
Alas, even if you give it the exact signature it wants, it does not succeed 😢 A diff that breaks all the other functions ( diff --git a/exhale/graph.py b/exhale/graph.py
index 54e57b9..f61319a 100644
--- a/exhale/graph.py
+++ b/exhale/graph.py
@@ -268,10 +268,11 @@ class ExhaleNode(object):
"""
if self.kind == "function":
# TODO: breathe bug with templates and overloads, don't know what to do...
- return "{name}({parameters})".format(
- name=self.name,
- parameters=", ".join(self.parameters)
- )
+ # return "{name}({parameters})".format(
+ # name=self.name,
+ # parameters=", ".join(self.parameters)
+ # )
+ return self.full_signature()
return self.name
@@ -290,9 +291,9 @@ class ExhaleNode(object):
"""
if self.kind == "function":
return "{template}{return_type} {name}({parameters})".format(
- template="template <{0}> ".format(", ".join(self.template)) if self.template is not None else "",
+ template="template<{0}> ".format(", ".join(self.template)) if self.template is not None else "",
return_type=self.return_type,
- name=self.name,
+ name=self.name.split("::")[-1],
parameters=", ".join(self.parameters)
)
raise RuntimeError(
@@ -2164,8 +2165,13 @@ class ExhaleRoot(object):
# 2. The function parameter list.
parameters = []
for param in memberdef.find_all("param", recursive=False):
- parameters.append(param.type.text)
- func.parameters = utils.sanitize_all(parameters)
+ p = utils.sanitize(param.type.text)
+ if param.declname:
+ p += " " + param.declname.text
+ parameters.append(p)
+
+ func.parameters = parameters
+
# 3. The template parameter list.
templateparamlist = memberdef.templateparamlist
if templateparamlist: |
Precisely what the title says. It does so by differentiating empty lists of template parameters from no template parameters at all.
Needs breathe-doc/breathe#750 (or
breathewon't pick specialized template functions to begin with).