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

documentation of '%r' links to the wrong repr #61861

Closed
Yhg1s opened this issue Apr 8, 2013 · 12 comments
Closed

documentation of '%r' links to the wrong repr #61861

Yhg1s opened this issue Apr 8, 2013 · 12 comments
Labels
docs Documentation in the Doc dir easy type-feature A feature request or enhancement

Comments

@Yhg1s
Copy link
Member

Yhg1s commented Apr 8, 2013

BPO 17661
Nosy @Yhg1s, @birkenfeld, @pitrou, @ezio-melotti, @merwok
Files
  • diff_style_example.PNG
  • diff_style_markup.PNG
  • using-ref.patch: Taking Kyle and Ezio comments into account.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-04-14.08:35:43.182>
    created_at = <Date 2013-04-08.12:32:38.012>
    labels = ['easy', 'type-feature', 'docs']
    title = "documentation of '%r' links to the wrong repr"
    updated_at = <Date 2013-04-14.08:35:43.180>
    user = 'https://github.com/Yhg1s'

    bugs.python.org fields:

    activity = <Date 2013-04-14.08:35:43.180>
    actor = 'python-dev'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2013-04-14.08:35:43.182>
    closer = 'python-dev'
    components = ['Documentation']
    creation = <Date 2013-04-08.12:32:38.012>
    creator = 'twouters'
    dependencies = []
    files = ['29771', '29772', '29801']
    hgrepos = []
    issue_num = 17661
    keywords = ['patch', 'easy']
    message_count = 12.0
    messages = ['186292', '186379', '186381', '186475', '186482', '186508', '186523', '186540', '186661', '186747', '186895', '186896']
    nosy_count = 9.0
    nosy_names = ['twouters', 'georg.brandl', 'pitrou', 'ezio.melotti', 'eric.araujo', 'docs@python', 'python-dev', 'kyle.roberts', 'dan.riti']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue17661'
    versions = ['Python 2.7']

    @Yhg1s
    Copy link
    Member Author

    Yhg1s commented Apr 8, 2013

    @Yhg1s Yhg1s added docs Documentation in the Doc dir easy labels Apr 8, 2013
    @merwok
    Copy link
    Member

    merwok commented Apr 9, 2013

    Thanks for catching this; Sphinx’ lookup is confusing sometimes. Using .repr or something similar will fix it.

    @birkenfeld
    Copy link
    Member

    It just highlights the mistake we made calling a builtin module the same name as a builtin function :)

    @kyleroberts
    Copy link
    Mannequin

    kyleroberts mannequin commented Apr 10, 2013

    Adding a '.' to the beginning (i.e. .repr) creates a link to repr.html#repr.repr. This made more sense after perusing Sphinx's documentation:

    "If you prefix the name with a dot, this order is reversed. For example, in the documentation of Python’s codecs module, :py:func:`open` always refers to the built-in function, while :py:func:`.open` refers to codecs.open()."

    I'm not sure what other options I can try after looking at the reST documentation. It seems like our best bet would be if we could define a priority for same-name functions when two definitions are discovered. I didn't see a way to do this in Sphinx/reST so I'm not sure how to move forward with this. I'm assuming we don't want to link directly to the correct url if it can be avoided.

    Also, I noticed http://docs.python.org/2/library/repr.html#module-repr links to the wrong repr() a few times where it mentions the "built-in" function.

    @pitrou
    Copy link
    Member

    pitrou commented Apr 10, 2013

    It just highlights the mistake we made calling a builtin module the
    same name as a builtin function :)

    But shouldn't the highlighting be handled by Pygments?
    ;)

    @merwok
    Copy link
    Member

    merwok commented Apr 10, 2013

    You can always use a ref role instead of func. func tries to find a module, class or function in the global Sphinx index, but ref lets you link to one specific target (see the table at the top of library/functions.rst for an example).

    @kyleroberts
    Copy link
    Mannequin

    kyleroberts mannequin commented Apr 10, 2013

    Ah that's the type of thing I was looking for, thanks Éric. I saw the underscored reference in functions.rst last night but figured it was just a local file link. I'll have a patch available later today. Thanks again.

    @kyleroberts
    Copy link
    Mannequin

    kyleroberts mannequin commented Apr 11, 2013

    So the :ref: keyword helps and creates a link, but it has the unfortunate side effect of adding different markup and style. I've attached two images to illustrate the differences. I couldn't find a way in the Sphinx or reST documentation to force it to style like a :func:, and my searches didn't come up with much either. Does anyone know of a way to style a :ref: just like a :func:?

    The code I used to create the fixed link is:

    :ref:`repr() <func-repr>`

    @ezio-melotti
    Copy link
    Member

    I don't think the style is so important, especially since this issue only affects 2.7.

    @ezio-melotti ezio-melotti added the type-feature A feature request or enhancement label Apr 12, 2013
    @danriti
    Copy link
    Mannequin

    danriti mannequin commented Apr 13, 2013

    Reproduced the issue and generated a patch following Kyle's documented approach.

    Please note that this patch addresses the link problem, but does not address the style issue. Thanks.

    @birkenfeld
    Copy link
    Member

    Fixed, thanks.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 14, 2013

    New changeset dd5e7aef4d5b by Georg Brandl in branch '2.7':
    Closes bpo-17661: fix references to repr() going to module repr.
    http://hg.python.org/cpython/rev/dd5e7aef4d5b

    @python-dev python-dev mannequin closed this as completed Apr 14, 2013
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir easy type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants