2

In one module, I have code such as:

class ConfigParsers:
    def str(raw, key):
        # parse value as a string
    # other parsers

class Section(dict):
    def add_parsers(name, parsers):
        """Add a parser

        :param str name: the name of the object
        ...
        ...

When sphinx builds the documentation for this module using autodoc, "str" gets linked to the current pages' ConfigParsers.str rather than the python documention. This occurs with other built in types where the name collision is within a class, such as int and bool. I can understand the collision if the parsers were defined at the module level, however Sphinx is forming a collision even when the definition is within a class, like above.

Edit:

A work around I have just found entails using the new intersphinx mapping format, and then using identifierusedforstdlibcode:str, however this isn't ideal, and normally wouldn't be an issue as sphinx usually autolinks it already to an extent.

13steinj
  • 427
  • 2
  • 9
  • 16
  • Try `:param .str name:`. That should reverse the lookup order. If it works, I'll post an answer with a link to the sphinx docs. – Mad Physicist Dec 21 '17 at 20:01
  • @MadPhysicist Unforunately, no dice. Still links to the function withing the ConfigParsers class instead of the builtin python class. I also tried `~__builtin__.str`, still failing. – 13steinj Dec 21 '17 at 20:16
  • You should add a tag for Python 2.7 then. I am pretty sure it's `builtins.str` in Py3: https://stackoverflow.com/q/11181519/2988730 – Mad Physicist Dec 21 '17 at 20:33

0 Answers0