-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Keep templates on adjacent lines #300
Keep templates on adjacent lines #300
Conversation
Thanks a lot for the PR. Could you also add a test case to |
That's cool! I wonder if the same thing could be used to separate each template argument in a different line for very long template signatures with default arguments... |
@vitaut: Not sure what to test for - are you content with simple text content? (ie, that this is not a regression from before from a text perspective? @arximboldi: That doesn't seem within the scope of breathe, and is probably a feature request for sphinx |
Ideally, showing that the output is rendered on separate lines as expected, but, if that's too hard, at least that the declaration including |
Sorry for breaking Breathe (again). Each signature is always a Also, there is now an option on the Sphinx directives, |
Guessing you're still waiting on a test here? |
@eric-wieser the test case for this can be really simple /// Testing render signature of template struct
template <class T, class U>
struct template_struct { }; with .. doxygenstruct:: template_struct I'm trying to track down the other template issues, but the above is enough to test the render signature. But then again, the existing template (and specialization) tests should already be sufficient? |
@svenevs: My issue was not knowing how to actually write the test - I wasn't able to find any clear example of what a breathe test looks like |
Templates are already built in As for the I took a look at the renderer tests to see if I could perhaps write one for templates. But indeed is isn't very clear. I'll see if I can manage somehow. If not, I intend to merge this anyway. I ran the changes on some personal projects and it looks a lot better with the RTD theme. |
@eric-wieser sorry for never responding, I didn't see your response. @melvinvermeeren I don't believe breathe currently supports a test for this. In theory, the test could look something like this: def test_template_struct_unspecialized():
# template <class T, class U> struct unspecialized_struct { };
member_def = TestMemberDef(
kind='struct', name='unspecialized_struct',
templateparamlist=[TestParam(type_='class T'), TestParam(type_='class U')]
)
signature = find_node(render(member_def), 'desc_signature')
# print(signature.astext())
assert signature.astext() == 'template <class T, class U> struct unspecialized_struct' This will fail for a couple of reasons, the more important of which is how breathe does its templates. My understanding is that two separate nodes are emitted, one for the The "right" thing to do here is probably figure out why <?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.8.13">
<compounddef id="structunspecialized__struct" kind="struct" language="C++" prot="public">
<compoundname>unspecialized_struct</compoundname>
<includes refid="test_8hpp" local="no">test.hpp</includes>
<templateparamlist>
<param>
<type>class T</type>
</param>
<param>
<type>class U</type>
</param>
</templateparamlist>
<briefdescription>
<para>An unspecialized template struct. </para> </briefdescription>
<detaileddescription>
</detaileddescription>
<location file="test.hpp" line="3" column="1" bodyfile="test.hpp" bodystart="3" bodyend="3"/>
<listofallmembers>
</listofallmembers>
</compounddef>
</doxygen> I can give you more information if you want, but really the point I'm trying to make here is that the current tests do not seem to support it, and I agree the PR here works well. In my opinion, since sphinx adopted |
@svenevs indeed, I noticed the tests were pretty broken on my own machine which has the latest Sphinx. Now I know why. Thank you for all this information, I didn't know most of this. I agree that it should be a separate issue. Perhaps a new test setup will happen one day, who knows? :) Thanks to all. |
Keep templates on adjacent lines
This is very visible on the ReadTheDocs theme, which draws two boxes, one around the template, and one around the rest of the signature:
Seems that sphinx 1.5 introduced a
desc_signature_line
that solves exactly this problem:This is how using the cpp domain renders templates, so it would be good if breathe were consistent
This ought to be backwards compatible with 1.4, giving the same behaviour as before