-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add support for more complicated documentation examples #8287
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
456157f
Add support for more than one code file in the documentation examples
DanielNoord d7fa654
Don't clear the FunctionalTestReporter.messages after each file
DanielNoord 13d1e3d
Allow testing of a directory of documentation examples
DanielNoord 5da0f81
Remove broken rcfile from ``empty_docstring`` test
DanielNoord 20a92ae
Fix test for ``plugin_does_not_exists``
DanielNoord bbfd103
[doc] Add an example for 'duplicate-code'
Pierre-Sassoulas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Apple: | ||
def __init__(self): | ||
self.remaining_bites = 3 | ||
|
||
def take_bite(self): | ||
if self.remaining_bites > 0: | ||
print("You take a bite of the apple.") | ||
self.remaining_bites -= 1 | ||
else: | ||
print("The apple is already eaten up!") | ||
|
||
def eaten_by_animal(self, animal): | ||
self.remaining_bites = 0 | ||
print("The apple has been eaten by an animal.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Orange: # [duplicate-code] | ||
def __init__(self): | ||
self.remaining_bites = 3 | ||
|
||
def take_bite(self): | ||
if self.remaining_bites > 0: | ||
print("You take a bite of the apple.") | ||
self.remaining_bites -= 1 | ||
else: | ||
print("The orange is already eaten up!") | ||
|
||
def eaten_by_animal(self, animal): | ||
if animal == "cat": | ||
raise ValueError("A cat would never do that !") | ||
self.remaining_bites = 0 | ||
print("The orange has been eaten by an animal.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
You can help us make the doc better `by contributing <https://github.com/PyCQA/pylint/issues/5953>`_ ! | ||
If you need to make a change to the logic or functionality of the duplicated | ||
code, you will need to identify all the places that need to be changed, which | ||
can be time-consuming and error-prone. If there are multiple copies of the | ||
same code, then you will also need to test each copy to ensure that the | ||
functionality is correct. Duplicate code can be confusing for someone who is | ||
trying to understand the logic and flow of the code if they come across multiple | ||
identical or nearly identical blocks of code. The reader can then skim and | ||
think something is identical when it actually isn't. This is particularly true | ||
during review. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from fruit import Fruit | ||
|
||
|
||
class Apple(Fruit): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Fruit: | ||
def __init__(self): | ||
self.remaining_bites = 3 | ||
|
||
def take_bite(self): | ||
if self.remaining_bites > 0: | ||
print(f"You take a bite of the {self.__class__.__name__.lower()}.") | ||
self.remaining_bites -= 1 | ||
else: | ||
print(f"The {self.__class__.__name__.lower()} is already eaten up!") | ||
|
||
def eaten_by_animal(self, animal): | ||
self.remaining_bites = 0 | ||
print(f"The {self.__class__.__name__.lower()} has been eaten by an animal.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from fruit import Fruit | ||
|
||
|
||
class Orange(Fruit): | ||
def eaten_by_animal(self, animal): | ||
if animal == "cat": | ||
raise ValueError("A cat would never do that !") | ||
super().eaten_by_animal(animal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice !