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

qthelp_namespace doesn't allow dashes #5035

Closed
NomAnor opened this issue Jun 2, 2018 · 6 comments
Closed

qthelp_namespace doesn't allow dashes #5035

NomAnor opened this issue Jun 2, 2018 · 6 comments
Labels
Milestone

Comments

@NomAnor
Copy link

NomAnor commented Jun 2, 2018

When setting the qthelp_namespace variable to a reverse URL with a dash the dash is removed. For example Qt uses org.qt-project.qtbluetooth.5110 as Namespace which would not be possible with the qthelp Builder because it would be changed to org.qtproject.qtbluetooth.5110.

I think namespaces should at least allow a reverse URL.

This code in sphinx.builders.qthelp tries to clean the namespace:

nspace = re.sub('[^a-zA-Z0-9.]', '', nspace)
nspace = re.sub(r'\.+', '.', nspace).strip('.')
nspace = nspace.lower()
@tk0miya
Copy link
Member

tk0miya commented Jun 5, 2018

Do you know the spec of namespace for qthelp?
I'd like to know what character is allowed for it.

@tk0miya tk0miya added this to the 1.8.0 milestone Jun 5, 2018
@NomAnor
Copy link
Author

NomAnor commented Jun 5, 2018

I tried to find it but the documentation for the file format is very sparse.

@NomAnor
Copy link
Author

NomAnor commented Jun 5, 2018

I think I found the code in qt5/qttools/src/assistant/help/qhelpprojectdata.cpp

} else if (name() == QLatin1String("namespace")) {
                namespaceName = readElementText();
                if (!hasValidSyntax(namespaceName, QLatin1String("test")))
                    raiseError(QCoreApplication::translate("QHelpProject",
                                   "Namespace \"%1\" has invalid syntax in file: \"%2\"").arg(namespaceName, fileName));

and then:

bool QHelpProjectDataPrivate::hasValidSyntax(const QString &nameSpace,
                                             const QString &vFolder) const
{
    const QLatin1Char slash('/');
    if (nameSpace.contains(slash) || vFolder.contains(slash))
        return false;
    QUrl url;
    const QLatin1String scheme("qthelp");
    url.setScheme(scheme);
    const QString &canonicalNamespace = nameSpace.toLower();
    url.setHost(canonicalNamespace);
    url.setPath(slash + vFolder);

    const QString expectedUrl(scheme + QLatin1String("://")
        + canonicalNamespace + slash + vFolder);
    return url.isValid() && url.toString() == expectedUrl;
}

So it looks like a valid namespace is the host part of an URL.

I think the plugin should not change the string in any way. If a user uses an invalid string the qt tools will tell them.

@tk0miya
Copy link
Member

tk0miya commented Jun 16, 2018

Thank you for comment. Good point!

@tk0miya
Copy link
Member

tk0miya commented Jun 16, 2018

I just made #5097. I simply added hyphens to our rule.

tk0miya added a commit that referenced this issue Jun 20, 2018
…shes

Close #5035: qthelp builder allows dashes in :confval:`qthelp_namespace`
@tk0miya
Copy link
Member

tk0miya commented Jun 20, 2018

Fixed by #5097.
Thank you for reporting

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants