-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
code and documentation for membergroups and members-only options #637
Conversation
If I understand correctly, by this you mean the actual class declaration? In that case it is rather complicated to implement. It is not just a header. .. doxygenclass:: someClass Breathe will execute directives in Sphinx corresponding to something like .. cpp:class:: someClass
.. cpp:function:: void someMemberFunction() so if you want to declare the members without the class then Breathe will still need to direct Sphinx to get into the scope of It may be that there is a better way of achieving what you would like. Can you provide a bit more context to your use case? Eg., is |
I have a project for which functionality for the classes people actually use is inherited from a number of different classes. The structure of that is not necessarily relevant to people just wanting to use the derived class. In my documentation, I follow a narrative that is focussed on what users are trying to do, which doesn't always match how these classes are structured. What would help me is a feature where I can create a member group and then pull only the members of that member group into the documentation, without anything else. Something like:
Analogous to :members:, which takes a comma-separated list of members, this would take a comma-separated list of member groups. The new option :members-only: would suppress both the name of the class and the name of the member group(s). This way documentation authors would be free to talk about a groups of members from anywhere, without having to go into what is inherited from where.
|
Thank for helping! Having spent all of yesterday on it, I'm glad you can confirm that it's not easy to do. ;-) As for |
It is indeed tedious, and in the optimal case Breathe should be able to produce alias declarations in this use case. Though, it may be possible to add support in Sphinx as well. In the near future I will merge some improvements to the alias directive (https://github.com/jakobandersen/sphinx/tree/c_cpp_alias) to insert nested declarations as aliases as well, and optionally skip the root symbol, which is interesting in your case as well. .. cpp:alias:: someClass
:noroot:
:maxdepth: 2
:filter: tag(someMemberGroup) The Sphinx issue for this is at sphinx-doc/sphinx#8213. Feel free to elaborate on suggestions for alias directive there. |
I'm super new to both sphinx and breathe, so I'll gladly take your word for it if you say this is better solved in sphinx than in breathe. At the end of the day, what I need is to get my list of members with nothing else, all just by putting them in the right member group in the header file. It'd be nice to be able to specify multiple groups, but that's not a big deal. Thanks for giving it thought !! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ropg Thanks a lot for the PR, the logic changes all seem good to me. I note from the discussion with @jakobandersen that this may not be the ideal solution, but I'm in favour of getting this merged and making a release after. For Breathe itself it's probably wise to one day more formally drop some legacy options and bump to version 5.
@ropg Have some minor comments, mostly about documentation. Could you check? When you are done, could you also rebase (git rebase -i upstream/master
) and fixup
the later commits into the initial one, so the commit history is clean?
Must admit I'm no git genius, and I've never used rebase/fixup. Seemsto me like something went wrong and I just created more commits instead of less. Commit 493c4a3 seems to incldue the previous ones, but i also still see them, they should be gone, no? |
@RobertoRoos You should have some form of upstream for the Breathe repo in your fork, you can check with git remote add upstream https://github.com/michaeljones/breathe.git Then Finally rebase, from the PR branch, on top of latest upstream with Feel free to post screenshot or commands if you need more help, I can also handle the rebase for you if you prefer that. See also https://git-scm.com/book/en/v2/Git-Branching-Rebasing and https://git-rebase.io/. Edit: note that after rebasing you have to force push with |
I think it worked as in it knows the upstream and did the rebase, it's just that the history of my branch still has the old commits too, as well as the new one that has it all-in-one, so I'm a bit confused. I'm not sure if maybe it's supposed to be this way and consolidation happens on merge... |
Ah, success!!! I had indeed pulled in the old state in between, |
42e2f09
to
f7142cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ropg Really nice with the updated docs and examples, thanks! Will make a release after checking the remaining PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ropg I did some final testing just prior to merging and found out this breaks the LaTeX build somehow, as make pdf
now results in the following:
LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.1719 \begin{fulllineitems}
?
The relevant section of the generated BreatheExample.tex
.
\subsubsection{Members\sphinxhyphen{}only}
\label{\detokenize{class:members-only}}\label{\detokenize{class:class-example-membersonly}}
This will only show the members of a class, and not the class name, child
classes or structs, or any information about the class.
\begin{sphinxVerbatim}[commandchars=\\\{\}]
\PYG{p}{..} \PYG{o+ow}{doxygenclass}\PYG{p}{::} ClassTest
\PYG{n+nc}{:project:} class
\PYG{n+nc}{:members:}
\PYG{n+nc}{:members\PYGZhy{}only:}
\end{sphinxVerbatim}
It produces this output:
\index{{[}anonymous{]}::ClassTest (C++ class)@\spxentry{{[}anonymous{]}::ClassTest}\spxextra{C++ class}}
\begin{fulllineitems}
~\index{{[}anonymous{]}::ClassTest::function (C++ function)@\spxentry{{[}anonymous{]}::ClassTest::function}\spxextra{C++ function}}
\begin{fulllineitems}
\phantomsection\label{\detokenize{class:_CPPv4NUt21_ex_class_members_only9ClassTest8functionEi}}%
\pysigstartmultiline
\pysiglinewithargsret{\phantomsection\label{\detokenize{class:classtestclass_class_test_1a6cd2a6337e41876f44d9825326d3bef1}}void \sphinxbfcode{\sphinxupquote{function}}}{int \sphinxstyleemphasis{myParameter}}{}%
\pysigstopmultiline
non\sphinxhyphen{}namespaced class function
More details in the header file.
More documentation in the impl file
\end{fulllineitems}
Somewhat difficult to see what the exact problem is, I notice old problems similar to this in #90 and #127, so perhaps a fix can you found there.
Can you investigate a bit to see which exact case in documentation causes the issue and do partial logic changes from there?
Problem found, not yet fixed. My trick to not have the class header with <paragraph>
It produces this output:
<index entries="['single',\ '[anonymous]::ClassTest\ (C++\ class)',\ '_CPPv4NUt21_ex_class_members_only9ClassTestE',\ '',\ None]">
<desc classes="cpp" desctype="class" domain="cpp" noindex="False" objtype="class">
<desc_content>
<container classes="breathe-sectiondef" objtype="public-func">
<index entries="['single',\ '[anonymous]::ClassTest::function\ (C++\ function)',\ '_CPPv4NUt21_ex_class_members_only9ClassTest8functionEi',\ '',\ None]">
<desc classes="cpp" desctype="function" domain="cpp" noindex="False" objtype="function">
<desc_signature ids="_CPPv4NUt21_ex_class_members_only9ClassTest8functionEi _CPPv3NUt21_ex_class_members_only9ClassTest8functionEi" is_multiline="True">
<desc_signature_line add_permalink="True" xml:space="preserve">
<target dupnames="classtestclass_class_test_1a6cd2a6337e41876f44d9825326d3bef1 classtestclass_class_test_1a6cd2a6337e41876f44d9825326d3bef1" ids="classtestclass_class_test_1a6cd2a6337e41876f44d9825326d3bef1">
void
<desc_name xml:space="preserve">
function
<desc_parameterlist xml:space="preserve">
<desc_parameter noemph="True" xml:space="preserve">
int
<emphasis>
myParameter
<desc_content>
<paragraph>
non-namespaced class function
<paragraph>
More details in the header file.
<paragraph>
More documentation in the impl file As you can see, unlike the embedded function, the class entry itself has no |
Even if I leave in the I can move the children up a level (that was one of my earlier tries, and worked) but that has its own problems, such as being very confusing in the readthedocs theme because the colors for the indent levels are different and then the function definitions look like class definitions all of a sudden. (Maybe you know a trick to change that? Just indenting the directive doesn't work: it does cause an indent, but still the wrong css class.) This feels too trial and error, given that I know way too little of Latex, docutils, sphinx and/or breathe. Please think along, I don't know how to figure out what is needed here. Darn... So close... -- BTW: I always get a lot of warnings when I compile documentation, like: [...]
writing output... [ 94%] typedef
writing output... [ 97%] union
writing output... [100%] variable
/Users/rop/Documents/github/breathe/documentation/source/class.rst:132: WARNING: cpp:identifier reference target not found: Tool
/Users/rop/Documents/github/breathe/documentation/source/class.rst:: WARNING: cpp:identifier reference target not found: QObject
/Users/rop/Documents/github/breathe/documentation/source/domains.rst:: WARNING: cpp:identifier reference target not found: testnamespace
/Users/rop/Documents/github/breathe/documentation/source/domains.rst:: WARNING: cpp:identifier reference target not found: testnamespace::NamespacedClassTest
/Users/rop/Documents/github/breathe/documentation/source/domains.rst:: WARNING: cpp:identifier reference target not found: testnamespace
[etc...] I also get this in the master branch, so is this something about my setup, or is this expected behaviour ? |
As for #637 (review), I think it's because you have paragraph breaks (i.e., double newline) inside the list environment (fulllineitems). |
Hmmm. I don't think those are mine, they are everywhere without issue. If I <container classes="breathe-sectiondef" objtype="private-func">
<rubric classes="breathe-sectiondef-title">
Private Functions
<index entries="['single',\ '[anonymous]::ClassTest::privateFunction\ (C++\ function)',\ '_CPPv4NKUt29_ex_class_members_undocumented9ClassTest15privateFunctionEv',\ '',\ None]">
<desc classes="cpp" desctype="function" domain="cpp" noindex="False" objtype="function">
<desc_signature ids="_CPPv4NKUt29_ex_class_members_undocumented9ClassTest15privateFunctionEv _CPPv3NKUt29_ex_class_members_undocumented9ClassTest15privateFunctionEv" is_multiline="True">
<desc_signature_line add_permalink="True" xml:space="preserve">
<target ids="classtestclass_class_test_1a13efc1addc97a75d6517df7f130615c3" names="classtestclass_class_test_1a13efc1addc97a75d6517df7f130615c3">
<desc_annotation xml:space="preserve">
virtual
void
<desc_name xml:space="preserve">
privateFunction
<desc_parameterlist xml:space="preserve">
<desc_annotation xml:space="preserve">
const
= 0
<desc_content>
<paragraph>
This is a private function.
<index entries="['single',\ '[anonymous]::ClassTest::undocumentedPrivateFunction\ (C++\ function)',\ '_CPPv4NKUt29_ex_class_members_undocumented9ClassTest27undocumentedPrivateFunctionEv',\ '',\ None]">
<desc classes="cpp" desctype="function" domain="cpp" noindex="False" objtype="function">
<desc_signature ids="_CPPv4NKUt29_ex_class_members_undocumented9ClassTest27undocumentedPrivateFunctionEv _CPPv3NKUt29_ex_class_members_undocumented9ClassTest27undocumentedPrivateFunctionEv" is_multiline="True">
<desc_signature_line add_permalink="True" xml:space="preserve">
<target ids="classtestclass_class_test_1a5d1966a5925affbedf4a9758ed23ba91" names="classtestclass_class_test_1a5d1966a5925affbedf4a9758ed23ba91">
<desc_annotation xml:space="preserve">
virtual
void
<desc_name xml:space="preserve">
undocumentedPrivateFunction
<desc_parameterlist xml:space="preserve">
<desc_annotation xml:space="preserve">
const
= 0
<desc_content> Will look at this further tomorrow... |
``membergroups`` If specified, only the groups in a comma-delimired list following this directive will be displayed. ``members-only`` This will allow to show only the members. It will remove group names, descriptions as well as the inheritance information.
OK, fixed and much, much cleaner now... As you can see, instead of removing the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ropg Apologies for the massive delay, stuff happened. New changes look good and I can confirm it solves the issue with PDF building. Thanks for documenting the CSS as well!
Yay! Thanks for merging. I learned a lot... |
This fixes issue #636 I filed yesterday, but only partly. This would be infinitely more useful if it could also suppress the header with the class name itself so the author is finally free to just discuss a set of members anywhere in documentation.
I cannot for the life of me figure out how to suppress these headings though. Please feel free to supersede this with a version that alse takes out these headings, which is really meant to be included in what my
members-only
option does.