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

Broken links in inheritance diagrams #3176

Closed
Paebbels opened this issue Nov 23, 2016 · 5 comments · Fixed by #10614
Closed

Broken links in inheritance diagrams #3176

Paebbels opened this issue Nov 23, 2016 · 5 comments · Fixed by #10614
Labels
extensions:graphviz The `sphinx.ext.graphviz` or `sphinx.ext.inheritance_diagram` extensions

Comments

@Paebbels
Copy link

This is a followup issue on #3164, which corrected inheritance diagrams.

HTML links in an inheritance diagram are broken if the target is defined in another Python module or package and hence in another HTML file. The Python documentation is generated by autoapi and stored in the folder docs/PyInfrastructure.

image

As you can see, exception classes defined in the same Python module are referenced with PyInfrastructure in the URL. Exception classes from an other module and/or package miss this part of the URL (second half of the image).

Project Structure:
--------------------------

Base/
    Exception.py
        class BaseException
        class SkipableException
    Compiler.py
        class CompilerException
        class SkipableCompilerException
@tk0miya
Copy link
Member

tk0miya commented Nov 23, 2016

Do you remember what I said in #3164?

It seems your project is already too complicated.
We can't determine it is a bug of Sphinx or not because of the 3rd party extensions you used.
Please try it with bare Sphinx before reporting, or doubt your extensions.

Could you show reproducible and minimal project without 3rd extensions please?

@Paebbels
Copy link
Author

The issue is the same even if I disable all extensions except for:

  • sphinx.ext.autodoc
  • sphinx.ext.inheritance_diagram
  • autoapi.sphinx

inheritance_diagram.py line 362..372:

    for child in node:
        if child.get('refuri') is not None:
            if graphviz_output_format == 'SVG':
                urls[child['reftitle']] = "../" + child.get('refuri')
                print("-- " + urls[child['reftitle']])
            else:
                urls[child['reftitle']] = child.get('refuri')
        elif child.get('refid') is not None:
            if graphviz_output_format == 'SVG':
                urls[child['reftitle']] = '../' + current_filename + '#' + child.get('refid')
                print("++ " + urls[child['reftitle']])
            else:
                urls[child['reftitle']] = '#' + child.get('refid')

Results in:

++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.DefaultAttribute
-- ../lib.pyAttribute.html#lib.pyAttribute.Attribute
-- ../lib.pyAttribute.html#lib.pyAttribute.Attribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.CommandAttribute
-- ../lib.pyAttribute.html#lib.pyAttribute.Attribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.ArgumentAttribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.SwitchArgumentAttribute
-- ../lib.pyAttribute.html#lib.pyAttribute.Attribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.ArgumentAttribute
-- ../lib.pyAttribute.html#lib.pyAttribute.Attribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.CommonArgumentAttribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.ArgumentAttribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.CommonSwitchArgumentAttribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.SwitchArgumentAttribute
-- ../lib.pyAttribute.html#lib.pyAttribute.Attribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.ArgumentAttribute
++ ../PyInfrastructure/lib.pyAttribute.ArgParseAttributes.html#lib.pyAttribute.ArgParseAttributes.ArgParseMixin
-- ../lib.pyAttribute.html#lib.pyAttribute.AttributeHelperMixin

So we see the missing URL path comes from line 365 child.get('refuri'), because the broken URLs are prefixed by two minus signs. I haven't found out where refuri is generated.


So I did another test and disabled a setting called: graphviz_output_format. This fixes the issue. So the questions are now:

  1. Why does sphinx.ext.inheritance_diagram use a configuration option from another extension (sphinx.ext.graphviz)?
  2. Why are the URLs partly false if the image rendering (svg + xlink vs. png + image map) is changed?

@tk0miya
Copy link
Member

tk0miya commented Nov 24, 2016

autoapi.sphinx

Sorry, autoapi.sphinx is not a part of sphinx.

Why does sphinx.ext.inheritance_diagram use a configuration option from another extension (sphinx.ext.graphviz)?

Because sphinx.ext.inheritance_diagram uses sphinx.ext.graphviz internally to draw diagrams.

Why are the URLs partly false if the image rendering (svg + xlink vs. png + image map) is changed?

In SVG case, the URL means a relative path from SVG file.
On the other hand, in PNG case, the URL means a relative path from HTML file.
The difference came from that Sphinx uses <object> tag to embed SVG files instead <img>.
So the URL of SVG becomes deeper than PNG's.

@dajose
Copy link

dajose commented Mar 23, 2020

I am seeing the same behavior, but I would rather not use png as it does not render pretty.

Is there a fix for svg?

@david-zwicker
Copy link

I still see this issue in recent versions of sphinx. Is there any chance the links in the SVG version of the graphs created for inheritance diagrams will be fixed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions:graphviz The `sphinx.ext.graphviz` or `sphinx.ext.inheritance_diagram` extensions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants