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

Comments vs docstrings #656

Merged
merged 3 commits into from
Jul 29, 2023
Merged

Comments vs docstrings #656

merged 3 commits into from
Jul 29, 2023

Conversation

martinosorb
Copy link
Contributor

This is meant to fix #464 but I'd love some feedback on how to succinctly describe the difference in use between comments and docstrings.

@github-actions
Copy link

github-actions bot commented Jul 24, 2023

Thank you!

Thank you for your pull request 😃

🤖 This automated message can help you check the rendered files in your submission for clarity. If you have any questions, please feel free to open an issue in {sandpaper}.

If you have files that automatically render output (e.g. R Markdown), then you should check for the following:

  • 🎯 correct output
  • 🖼️ correct figures
  • ❓ new warnings
  • ‼️ new errors

Rendered Changes

🔍 Inspect the changes: https://github.com/swcarpentry/python-novice-gapminder/compare/md-outputs..md-outputs-PR-656

The following changes were observed in the rendered markdown documents:

 18-style.md | 8 ++++++++
 md5sum.txt  | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
What does this mean?

If you have source files that require output and figures to be generated (e.g. R Markdown), then it is important to make sure the generated figures and output are reproducible.

This output provides a way for you to inspect the output in a diff-friendly manner so that it's easy to see the changes that occur due to new software versions or randomisation.

⏱️ Updated at 2023-07-29 00:59:09 +0000

github-actions bot pushed a commit that referenced this pull request Jul 24, 2023
Copy link
Member

@alee alee left a comment

Choose a reason for hiding this comment

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

A solid start! How about

Use comments to describe and help others understand potentially unintuitive sections or individual lines of code.

Use docstrings to document the expected inputs and outputs of a method or class, its purpose, and/or assumptions and contracts it is expected to uphold. Docstrings are displayed when a user invokes the builtin `help` method on your method or class.

@martinosorb
Copy link
Contributor Author

Ok, I followed your suggestion with a minor addition:

Use comments to describe and help others understand potentially unintuitive
sections or individual lines of code. They are especially useful to whoever may
need to edit your code in the future, including yourself.

Use docstrings to document the expected inputs and outputs of a method or class,
its purpose, assumptions and intended behavior. Docstrings are displayed
when a user invokes the builtin `help` method on your method or class.

github-actions bot pushed a commit that referenced this pull request Jul 26, 2023
Copy link
Member

@alee alee left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @martinosorb !

github-actions bot pushed a commit that referenced this pull request Jul 29, 2023
@alee alee merged commit 703664a into main Jul 29, 2023
3 checks passed
@alee alee deleted the martinosorb-patch-2 branch July 29, 2023 00:59
github-actions bot pushed a commit that referenced this pull request Jul 29, 2023
Auto-generated via {sandpaper}
Source  : 703664a
Branch  : main
Author  : Allen Lee <alee@users.noreply.github.com>
Time    : 2023-07-29 00:59:50 +0000
Message : Merge pull request #656 from swcarpentry/martinosorb-patch-2

add more detailed description of comments vs docstrings
github-actions bot pushed a commit that referenced this pull request Jul 29, 2023
Auto-generated via {sandpaper}
Source  : 3ef02ed
Branch  : md-outputs
Author  : GitHub Actions <actions@github.com>
Time    : 2023-07-29 01:01:15 +0000
Message : markdown source builds

Auto-generated via {sandpaper}
Source  : 703664a
Branch  : main
Author  : Allen Lee <alee@users.noreply.github.com>
Time    : 2023-07-29 00:59:50 +0000
Message : Merge pull request #656 from swcarpentry/martinosorb-patch-2

add more detailed description of comments vs docstrings
github-actions bot pushed a commit that referenced this pull request Aug 1, 2023
Auto-generated via {sandpaper}
Source  : 3ef02ed
Branch  : md-outputs
Author  : GitHub Actions <actions@github.com>
Time    : 2023-07-29 01:01:15 +0000
Message : markdown source builds

Auto-generated via {sandpaper}
Source  : 703664a
Branch  : main
Author  : Allen Lee <alee@users.noreply.github.com>
Time    : 2023-07-29 00:59:50 +0000
Message : Merge pull request #656 from swcarpentry/martinosorb-patch-2

add more detailed description of comments vs docstrings
github-actions bot pushed a commit that referenced this pull request Aug 8, 2023
Auto-generated via {sandpaper}
Source  : 3ef02ed
Branch  : md-outputs
Author  : GitHub Actions <actions@github.com>
Time    : 2023-07-29 01:01:15 +0000
Message : markdown source builds

Auto-generated via {sandpaper}
Source  : 703664a
Branch  : main
Author  : Allen Lee <alee@users.noreply.github.com>
Time    : 2023-07-29 00:59:50 +0000
Message : Merge pull request #656 from swcarpentry/martinosorb-patch-2

add more detailed description of comments vs docstrings
github-actions bot pushed a commit that referenced this pull request Aug 15, 2023
Auto-generated via {sandpaper}
Source  : 3ef02ed
Branch  : md-outputs
Author  : GitHub Actions <actions@github.com>
Time    : 2023-07-29 01:01:15 +0000
Message : markdown source builds

Auto-generated via {sandpaper}
Source  : 703664a
Branch  : main
Author  : Allen Lee <alee@users.noreply.github.com>
Time    : 2023-07-29 00:59:50 +0000
Message : Merge pull request #656 from swcarpentry/martinosorb-patch-2

add more detailed description of comments vs docstrings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants