Role created by custom xref types fails to insert xref link

Ramiro Morales avatarRamiro Morales created an issue

Django docs define four custom xref types:

When creating the HTML output with sphinx-1.0 tip as of now (post 1.0.1) only the first one (the 'setting' xref type) inserts HTML links on the output.

Running the build with nitpicky = True shows all the cross references reported as broken, with domain std.

Things tried, to no avail:

  • Adding :std: prefix to the xrefs (ttag:`foo` -> :std:ttag:`foo`)
  • Adding std: prefix to the directives (.. templatetag:: foo -> .. std:templatetag:: foo)
  • Both the above.

Finally found the cause seems to be having the directivename parameter value ("templatetag") different from the value of the rolename ("ttag") parameter in the add_crossref_type() call. Changing the directives to .. ttag:: foo and the API call to app.add_crossref_type(directivename="ttag", rolename="ttag", indextemplate="pair: %s; template tag") solves the problem.

Django docs also add two custom object types and cross reference links generation fails for them too, although their parse functions are simple enough, similar to the one included for the custom 'event' object on Sphinx's I suspect the root cause could be the same as above.

Sphinx 0.6 doesn't show this behavior.

Comments (3)

  1. Ramiro Morales

    The test case for the 'userdesc' custom objects included with Sphinx already uses a directive name different from the role name so it can show the bug. But currently it fails to check for the link markup. The attached patch for the test fixes that.

    diff -r e64145e91dc3 tests/
    --- a/tests/	Thu Aug 05 22:35:12 2010 +0200
    +++ b/tests/	Sat Aug 07 15:28:21 2010 -0300
    @@ -167,6 +167,7 @@
             (".//dl[@class='userdesc']", ''),
             (".//dt[@id='userdesc-myobj']", ''),
             (".//a[@href='#userdesc-myobj']", ''),
    +        (".//a[@href='#userdescrole-myobj']", ''),
             # C references
             (".//span[@class='pre']", 'CFunction()'),
             (".//a[@href='#Sphinx_DoSomething']", ''), 
  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.