Skip to content

Fix idlelib.help comments#15669

Merged
terryjreedy merged 2 commits into
python:masterfrom
terryjreedy:help_comments
Sep 5, 2019
Merged

Fix idlelib.help comments#15669
terryjreedy merged 2 commits into
python:masterfrom
terryjreedy:help_comments

Conversation

@terryjreedy

Copy link
Copy Markdown
Member

Format comments as sentences and use sentences when possible.

@terryjreedy

Copy link
Copy Markdown
Member Author

@taleinat I made minor changes to comment texts and will consider a few more.

I think I found a mismatch between indent() and one of its calls.

    def indent(self, amt=1):
        "Change indent (+1, 0, -1) and tags."
        self.level += amt
        self.tags = '' if self.level == 0 else 'l'+str(self.level)
    ...    
        if tag in ['h1', 'h2', 'h3']:
            self.indent(0)  # Clear tag, reset indent.

The comment asserts that self.indent(0) will set self.level to 0 and then self.tags to ''. But it leaves self.level alone and only resets self.tags if self.level was already 0. As it turns out, the latter is always true, as I would expect it to be if +1s and -1s are properly matched. So I think the call should be replaced with self.tags = '', possible preceded by assert self.level == 0.

@taleinat

taleinat commented Sep 4, 2019

Copy link
Copy Markdown
Contributor

I think I found a mismatch between indent() and one of its calls.

I noticed that too but didn't investigate.

I suggest separating into three methods: indent(), dedent() and reset_indent().

@taleinat taleinat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment changes look fine to me.

Comment thread Lib/idlelib/help.py Outdated
Comment thread Lib/idlelib/help.py Outdated
@terryjreedy

Copy link
Copy Markdown
Member Author

After more thought, I went with assert at the beginning of the block, as I am pretty sure level != 0 would indicate an error somewhere. The set tags at the end of the block, as done for other blocks.

@terryjreedy
terryjreedy merged commit 6cd9666 into python:master Sep 5, 2019
@terryjreedy
terryjreedy deleted the help_comments branch September 5, 2019 00:20
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @terryjreedy for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-15683 is a backport of this pull request to the 3.8 branch.

@bedevere-bot

Copy link
Copy Markdown

GH-15684 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 5, 2019
(cherry picked from commit 6cd9666)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 5, 2019
(cherry picked from commit 6cd9666)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
miss-islington added a commit that referenced this pull request Sep 5, 2019
(cherry picked from commit 6cd9666)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
miss-islington added a commit that referenced this pull request Sep 5, 2019
(cherry picked from commit 6cd9666)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
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 skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants