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

Add various specifiers to functions and variables #628

Merged
merged 2 commits into from
Feb 2, 2021

Conversation

jakobandersen
Copy link
Collaborator

Convert various specifiers on functions and variables.

Fixes (part 1 of) #600.

@jakobandersen
Copy link
Collaborator Author

Example to check the rendering:

struct A {
	static void fStatic();
	inline void fInline();
	friend void fFriend();
	virtual void fPureVirtual() = 0;
	virtual void fVirtual();
	explicit A();
	constexpr void fConstexpr();
public:
	static int vStatic;
	mutable int vMutable;
};

// doc
extern void fExtern();
// doc
thread_local int vThreadLocal;
.. doxygenstruct:: A
	:members:
	:undoc-members:

.. doxygenfunction:: fExtern
.. doxygenvariable:: vThreadLocal

@jakobandersen
Copy link
Collaborator Author

(The linting errors seems to be unrelated to the PR but due to a new mypy version.)

@vermeeren vermeeren self-requested a review February 2, 2021 15:28
@vermeeren vermeeren self-assigned this Feb 2, 2021
@vermeeren vermeeren added code Source code enhancement Improvements, additions (also cosmetics) labels Feb 2, 2021
These errors newly occur in CICD, likely a new mypy version was pulled
in recently. Ignore the entire file as it's just configuration settings.
Copy link
Collaborator

@vermeeren vermeeren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks @jakobandersen !

michaeljones pushed a commit that referenced this pull request Feb 2, 2021
@michaeljones michaeljones merged commit fc36785 into breathe-doc:master Feb 2, 2021
@jakobandersen jakobandersen deleted the specifiers branch February 2, 2021 16:33
@ninkibah
Copy link

Is there a way to not output an inline specifier? My code is highly templated C++, where the functions are all implemented inline, although without the explicit specifier. All of these function templates are marked as inline in the documentation and it's ugly and I would prefer they were not shown.

I presume Doxygen is passing on these specifier to breathe. If there's a workaround using doxygen, I'd be happy to try that.

@jakobandersen
Copy link
Collaborator Author

I don't think Breathe has options to do that, and I don't know about Doxygen. Theoretically, if there are all templates, the inline specifier is redundant as far as I remember. Though, I guess the compilers may still use it as a slight hint for function inlining.

@ninkibah
Copy link

Sorry if I wasn't explicit enough. I write code like:

template<typename T>
void foo(T&) {}

This function will end up being marked as inline in the HTML documentation generated by Sphinx. That's what I was hoping to avoid.

@ninkibah
Copy link

I've raised an issue on the doxygen project, where, I believe, the problem lies:
doxygen/doxygen#8458

I think this issue can be closed.

For anybody who is looking for a quick workaround, I was able to add a little jquery script in custom.js to hide the inline specifier from the HTML.

In conf.py:

html_js_files = [
    'custom.js'
]

In _static/custom.js, I added the following:

$(document).ready(function() {
  $("em.property > span.pre:contains('inline')").hide();
});

This works for the readthedocs theme. Other themes may use different selectors. That's beyond my sphinx knowledge.

@jakobandersen
Copy link
Collaborator Author

I'm not exactly sure what the rationale for why Doxygen marks it inline when it's a member function and not when it's an ordinary function, but in any case: your hax will definitely remove them.
Just as a heads up: this will break if/when sphinx-doc/sphinx#9023 gets merged. Though something like .sig.cpp .k > span.pre:contains('inline') is the most specific selector I can think will work then.

@ninkibah
Copy link

Jakob, thanks very much for the advice. The spacing in declarations is not always great, so I hope that the above issue makes it easier to make the spacing look nice. I should probably talk to the readthedocs theme people about this.

@jakobandersen
Copy link
Collaborator Author

Oh, right, I just tried locally and I don't see any spacing and wrapping issues with that PR + sphinx_rtd_theme!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Source code enhancement Improvements, additions (also cosmetics)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants