-
Notifications
You must be signed in to change notification settings - Fork 1.3k
issue #11245 Add class attribute to the @qualifier
command in the HTML output
#11250
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
base: master
Are you sure you want to change the base?
Conversation
…n the HTML output Adding the possibility to have (HTML) class attribute values as options with the `@qualifier` command.
…n the HTML output Removing pedantic warning
@albert-github I think there is a more local change possible, that doesn't require the user to specify any extra options, and also provides the possibility to style existing labels. My idea is to derive the class from the label automatically, like so: void HtmlGenerator::writeLabel(const QCString &label,bool /*isLast*/)
{
DBG_HTML(m_t << "<!-- writeLabel(" << label << ") -->\n";)
auto convertLabelToClass = [](const std::string &lab) -> QCString {
QCString input = convertUTF8ToLower(lab);
QCString result;
size_t l=input.length()+1;
result.reserve(l);
result+=' ';
for (size_t i=0; i<l; i++)
{
char c = input.at(i);
if (isId(c) || c<0) result+=c;
else if (c==' ' || c=='-') result+='-';
}
return result;
};
m_t << "<span class=\"mlabel" << convertLabelToClass(label.stripWhiteSpace().str()) << "\">" << label << "</span>";
} This way /** \qualifier Thread-Safe
* \qualifier "Some other qualifier"
* More docs
*/
inline void nvs_init() {} will make Doxygen generate the labels like this: <span class="mlabels">
<span class="mlabel inline">inline</span>
<span class="mlabel thread-safe">Thread-Safe</span>
<span class="mlabel some-other-qualifier">Some other qualifier</span>
</span> Let me know what you think. Note that turning specific spans into links can be done with a bit of JavaScript. |
In principle it doesn't look bad, but it will mean that with each qualifier an extra part will be added to the class attribute (argument with PR 11243). From the given example I understand that the "default" labels also get automatically a class attribute, that is good (was enlarging my proposed code change a bit). The The remark:
what do you mean here I don't get it, the "class" are steered through the css are does the JS give some other / extra flexibility? Furthermore there is the enhancement request #11247 ([Feature Request] Add support for |
In this case it is justified, as all qualifiers have the same span and cannot be distinguished.
I think it is indeed more flexibility, but at the cost of the user having to specify things explicitly, so a bit overly flexible in my opinion. It is always a trade-off of course.
Indeed. I found the spec, and can change it to void HtmlGenerator::writeLabel(const QCString &label,bool /*isLast*/)
{
DBG_HTML(m_t << "<!-- writeLabel(" << label << ") -->\n";)
auto convertLabelToClass = [](const std::string &lab) {
QCString input = convertUTF8ToLower(lab);
QCString result;
size_t l=input.length();
result.reserve(l);
// Create valid class selector, see 10.2 here https://www.w3.org/TR/selectors-3/#w3cselgrammar
// ident [-]?{nmstart}{nmchar}*
// nmstart [_a-z]|{nonascii}
// nonascii [^\0-\177]
// nmchar [_a-z0-9-]|{nonascii}
bool nmstart=false;
for (size_t i=0; i<l; i++)
{
char c = input.at(i);
if (c<0 || (c>='a' && c<='z') || c=='_') // nmstart pattern
{
nmstart=true;
result+=c;
}
else if (nmstart && (c<0 || (c>='a' && c<='z') || (c>='0' && c<='9') || c=='_')) // nmchar pattern
{
result+=c;
}
else if (nmstart && (c==' ' || c=='-')) // show whitespace as -
{
result+='-';
}
}
return result;
};
m_t << "<span class=\"mlabel " << convertLabelToClass(label.stripWhiteSpace().str()) << "\">" << label << "</span>";
}
I was indeed referring to the enhancement request. You can do this also by embedding a piece of JavaScript in the header, e.g. $(document).ready(function() {
$('span.thread-safe').each(function() {
var spanContent = $(this).text();
$(this).replaceWith('<span class="mlabel thread-safe"><a href="https://en.wikipedia.org/wiki/Thread_safety">' + spanContent + '</a></span>');
});
}); |
|
Ok, interesting.
No, but is that really something someone wants to do? Sounds a bit farfetched to me. This particular example could also be handled in an automated way by adding a language identifier as a class specifier.
Good point. This would indeed require it be processed by Doxygen. But if |
|
Adding the possibility to have (HTML) class attribute values as options with the
@qualifier
command.