Skip to content

Commit

Permalink
docs: fix code comment formatting (#1153)
Browse files Browse the repository at this point in the history
* docs(branch.rst): Line number comments not needed

The topic `Branch Coverage Management` in this file
already has a setting:

        :linenothreshold: 5

Using this setting, sphinx will automatically provide
line numbers for code block longer than 5 lines.

reference: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-option-highlight-linenothreshold

* docs: Extra spaces in comment (maybe intentional)

The lines edited in this commit might have been given
extra indentation purposefully.
As they are an instruction for coverage py and are immediately
followed by another comment that is not for coveragepy.

* docs: inconsistent spaces in comments

Fix extra indentations or lack of indentations.
  • Loading branch information
storymode7 committed Apr 30, 2021
1 parent 1b23b79 commit 78fa3d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions doc/branch.rst
Expand Up @@ -17,10 +17,10 @@ and flags lines that haven't visited all of their possible destinations.

For example::

def my_partial_fn(x): # line 1
if x: # 2
y = 10 # 3
return y # 4
def my_partial_fn(x):
if x:
y = 10
return y

my_partial_fn(1)

Expand Down Expand Up @@ -78,7 +78,7 @@ as a branch if one of its choices is excluded::
if x:
blah1()
blah2()
else: # pragma: no cover
else: # pragma: no cover
# x is always true.
blah3()

Expand Down Expand Up @@ -108,7 +108,7 @@ tell coverage.py that you don't want them flagged by marking them with a
pragma::

i = 0
while i < 999999999: # pragma: no branch
while i < 999999999: # pragma: no branch
if eventually():
break

Expand Down
2 changes: 1 addition & 1 deletion doc/cmd.rst
Expand Up @@ -517,7 +517,7 @@ For example::

> def h(x):
"""Silly function."""
- if 0: #pragma: no cover
- if 0: # pragma: no cover
- pass
> if x == 1:
! a = 1
Expand Down
6 changes: 3 additions & 3 deletions doc/excluding.rst
Expand Up @@ -17,7 +17,7 @@ Coverage.py will look for comments marking clauses for exclusion. In this
code, the "if debug" clause is excluded from reporting::

a = my_function1()
if debug: # pragma: no cover
if debug: # pragma: no cover
msg = "blah blah"
log_message(msg, a)
b = my_function2()
Expand All @@ -32,7 +32,7 @@ function is not reported as missing::
blah1()
blah2()

def __repr__(self): # pragma: no cover
def __repr__(self): # pragma: no cover
return "<MyObject>"

Excluded code is executed as usual, and its execution is recorded in the
Expand All @@ -50,7 +50,7 @@ counted as a branch if one of its choices is excluded::
if x:
blah1()
blah2()
else: # pragma: no cover
else: # pragma: no cover
# x is always true.
blah3()

Expand Down

0 comments on commit 78fa3d9

Please sign in to comment.