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

MatchObject is not a hyperlink in the 're' module documentation #50787

Closed
bitdancer opened this issue Jul 21, 2009 · 19 comments
Closed

MatchObject is not a hyperlink in the 're' module documentation #50787

bitdancer opened this issue Jul 21, 2009 · 19 comments
Assignees
Labels
docs Documentation in the Doc dir easy type-bug An unexpected behavior, bug, or error

Comments

@bitdancer
Copy link
Member

BPO 6538
Nosy @birkenfeld, @terryjreedy, @amauryfa, @tiran, @ezio-melotti, @bitdancer, @briancurtin, @serhiy-storchaka
Files
  • MatchObjectLinksFix.diff
  • issue6538_corrections.diff: py3k patch
  • 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 = 'https://github.com/birkenfeld'
    closed_at = <Date 2010-07-29.11:50:47.880>
    created_at = <Date 2009-07-21.22:29:21.463>
    labels = ['easy', 'type-bug', 'docs']
    title = "MatchObject is not a hyperlink in the 're' module documentation"
    updated_at = <Date 2012-12-24.08:37:24.365>
    user = 'https://github.com/bitdancer'

    bugs.python.org fields:

    activity = <Date 2012-12-24.08:37:24.365>
    actor = 'serhiy.storchaka'
    assignee = 'georg.brandl'
    closed = True
    closed_date = <Date 2010-07-29.11:50:47.880>
    closer = 'georg.brandl'
    components = ['Documentation']
    creation = <Date 2009-07-21.22:29:21.463>
    creator = 'r.david.murray'
    dependencies = []
    files = ['16427', '18245']
    hgrepos = []
    issue_num = 6538
    keywords = ['patch', 'easy']
    message_count = 19.0
    messages = ['90776', '99644', '100116', '100123', '100133', '100379', '100684', '100688', '100691', '100722', '101739', '111874', '111876', '111883', '111884', '111885', '111890', '111913', '178037']
    nosy_count = 10.0
    nosy_names = ['georg.brandl', 'terry.reedy', 'amaury.forgeotdarc', 'christian.heimes', 'ezio.melotti', 'r.david.murray', 'brian.curtin', 'Asheesh.Laroia', 'rarana', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue6538'
    versions = ['Python 2.6', 'Python 3.1', 'Python 2.7', 'Python 3.2']

    @bitdancer
    Copy link
    Member Author

    In the re documentation MatchObject is marked up as a class, but since
    there's no declaration of it as a class (it's a section instead) it
    doesn't get turned into a hyperlink. It would be useful if it did link
    to the appropriate section.

    @bitdancer bitdancer added docs Documentation in the Doc dir easy labels Jul 21, 2009
    @rarana
    Copy link
    Mannequin

    rarana mannequin commented Feb 21, 2010

    Changed all occurrences of :class:`MatchObjects` to :ref:`match-objects` in /Doc/library/re.rst

    These changes were made to rev 78277.

    @AsheeshLaroia
    Copy link
    Mannequin

    AsheeshLaroia mannequin commented Feb 25, 2010

    Hey all,

    I think this is ready. Can someone review the patch?

    @amauryfa
    Copy link
    Member

    It would be simpler to add a ".. class:: MatchObject" directive.
    Also, RegexpObject should be handled as well.

    @AsheeshLaroia
    Copy link
    Mannequin

    AsheeshLaroia mannequin commented Feb 26, 2010

    Ryan -- would you take a further look at this?

    @rarana
    Copy link
    Mannequin

    rarana mannequin commented Mar 4, 2010

    Added .. class:: MatchObject and .. class:: RegexObject directives.

    @AsheeshLaroia
    Copy link
    Mannequin

    AsheeshLaroia mannequin commented Mar 9, 2010

    Hey Ryan,

    I took a look at the diff you attached here. It looks like you did

    There are some whitespace-only changes -- for example, you remove and then re-insert the line beginning with "The name of the last matched capturing group".

    Can you re-submit your most recent patch without the unneeded whitespace-only changes?

    There's a light at the end of the tunnel!

    @briancurtin
    Copy link
    Member

    I've reviewed the patch and do not see any unnecessary whitespace changes in his patch.

    @rarana
    Copy link
    Mannequin

    rarana mannequin commented Mar 9, 2010

    I tried to format the methods of the class(es) as they are formatted in other files, which is why I added the whitespace.

    I can go back and remove that if that's what would be preferred.

    @AsheeshLaroia
    Copy link
    Mannequin

    AsheeshLaroia mannequin commented Mar 9, 2010

    Er, ignore my comment then!

    If this is reviewed, can it get committed?

    @briancurtin
    Copy link
    Member

    Fixed in trunk (r79430), release26-maint (r79631), py3k (r79434), and release31-maint (r79435). Thanks for the patch.

    @briancurtin briancurtin added the type-bug An unexpected behavior, bug, or error label Mar 26, 2010
    @terryjreedy
    Copy link
    Member

    I believe these patches are wrong, at least in part, and should be reverted.

    1.The re module no longer has either a class RegexObject or a class MatchObject. (They are now _sre.SRE_Pattern and _sre.SRE_Match.) So
    the previous reference to them as anonymous "Compiled regular expression objects" and "Match objects" (lower case 'objects') was correct, certainly more correct that marking the fake names as real code. In other words. 'MatchObject' should be removed, not hyperlinked.

    This issue came up today on python-list when someone tried "help(re.MatchObject)" and got a module attribute error. I was about to open a new issue when I discovered this one. I recommend changing the re.match entry from "return a corresponding MatchObject instance." to "return a match object" (which is what the current doc string says) and removing all the misleading RegexObject and MatchObject fake-class method prefixes, The prefixes are present in 2.6 and already removed in 2.7. I think they should also be removed from the 3.x docs. (Unless, of course, re is changed to add/reinstate those names, which could only happen in 3.2.)

    1. I believe it is the policy that the 3.x docs 'start fresh' with 3.0. Ancient back-compatibility notes like

    "(Incompatibility note: in the original Python 1.5 release, if the tuple was one element long, a string would be returned instead. In later versions (from 1.5.1 on), a singleton tuple is returned in such cases.)"

    were intentionally, not accidentally, removed in 3.0. So I think it a mistake to put revert the removal and that the reversion should be reverted.

    1. This is more of a question. I have noticed that optional parameters with defaults are sometimes bracketed and sometimes not. Since the brackets are redundant, I prefer without as less cluttered and so I question the addition in the 3.2 patch. But is there a definitive current doc style guide? In any case, removing the default value while changing 'group=0' to '[group]' seems wrong.

    @terryjreedy terryjreedy assigned tiran and unassigned briancurtin Jul 28, 2010
    @terryjreedy terryjreedy reopened this Jul 28, 2010
    @briancurtin
    Copy link
    Member

    I'm guessing assigning to Christian was accidental - taking it back for myself.

    @briancurtin briancurtin assigned briancurtin and unassigned tiran Jul 28, 2010
    @briancurtin
    Copy link
    Member

    How does this patch look? It changes RegexObject to _sre.SRE_Pattern and MatchObject to _sre.SRE_Match. Additionally, references are used to link to those classes generically as "match objects" or "compiled regular expressions" rather than the fake classes used before.

    @ezio-melotti
    Copy link
    Member

    The patch looks good to me, but I'm not sure if it's a good idea to use _sre.SRE_*. I think these are implementation details and even if they should be mentioned somewhere, they "clutter" the doc IMHO.

    1. I believe it is the policy that the 3.x docs 'start fresh' with 3.0.

    Yes, they should be removed.

    1. [...] In any case, removing the default value while changing 'group=0' to '[group]' seems wrong.

    If it's possible to specify a default value the [] should be avoided.

    @briancurtin
    Copy link
    Member

    I didn't actually want to use _sre.SRE_* but I'm not exactly sure how to hide it. It's more correct that way, but it takes this issue the wrong direction by exposing it.

    I think it should be denoted as a class but with a generic name, if that's even possible. It would actually be nice if the lines "class _sre.*" were just invisible.

    @bitdancer
    Copy link
    Member Author

    Please note that my original suggestion was to make them *section* links (:ref:s). As Terry says, they are not real classes and should not be marked up as such. Nor should the internal class names be exposed.

    Terry: [] notation is 2.x, they should all be gone (with the possible exception of a few C functions) in the 3.x docs.

    @birkenfeld
    Copy link
    Member

    Should be fixed now in r83218. I've removed the "class" directives, and put generic class name substitutes "regex" and "pattern" in the method descriptions, like we do for "contextmanager.__enter__". I've also removed the compatibility info, and removed [] style arguments where feasible.

    @serhiy-storchaka
    Copy link
    Member

    I have opened a new bpo-16760 for regex HOWTO.

    @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-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    8 participants