-
Notifications
You must be signed in to change notification settings - Fork 20
Add CODE_STYLE.md #623
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
Open
laurenchilutti
wants to merge
6
commits into
NOAA-GFDL:main
Choose a base branch
from
laurenchilutti:style
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add CODE_STYLE.md #623
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
676944a
first commit of a code style guide
laurenchilutti a6cb050
rename to all caps CODE_STYLE.md Update minor things.
laurenchilutti 16260b9
updating resources links in code style guide
laurenchilutti eed2e26
clean up renamed file
laurenchilutti 1a50b46
Update ok-unknown-words.txt
laurenchilutti 2f6004e
update code_style guide per comments
laurenchilutti 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 hidden or 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 |
---|---|---|
|
@@ -219,6 +219,7 @@ INTERP | |
intrafile | ||
ISMIP | ||
isodatetime | ||
ivar | ||
jaon | ||
jhan | ||
jhanbigmem | ||
|
This file contains hidden or 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,88 @@ | ||
# FRE Code Style Guide | ||
|
||
Follow these Style Guidelines when contributing to the `fre-cli` repository. | ||
|
||
## General Documentation Tips | ||
|
||
Here are some things to keep in mind when writing documentation: | ||
- Keep sentences short | ||
- Avoid the use of pronouns (this, that, it, etc) | ||
- Use the imperative mood (the subject you is understood) for procedures | ||
- E.g. “Go to www.google.com”; “Install Conda” | ||
laurenchilutti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Write in active voice rather than passive | ||
- Write objectively (do not include humor, jargon, idioms, etc) | ||
laurenchilutti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Useful Resources: | ||
- https://docs.openstack.org/doc-contrib-guide/writing-style/general-writing-guidelines.html | ||
|
||
## Inline Python Documentation Requirements | ||
laurenchilutti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Document classes and functions with field lists for all Python files. You do not need to document click interface | ||
functions with field lists. | ||
laurenchilutti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Document classes, variables and functions with type hinting. It is encouraged to document click interface functions | ||
with type hinting | ||
|
||
Useful Resources | ||
- https://docs.python.org/3/library/typing.html | ||
- https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html | ||
- https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#field-lists | ||
- https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html | ||
|
||
An Example: | ||
|
||
```python | ||
from typing import Any, List, ClassVar | ||
|
||
class MyClass(object): | ||
""" | ||
Description for class | ||
|
||
:cvar str var3: description | ||
:ivar str var1: description, initial value: par1 | ||
:ivar str var2: description, initial value: par2 | ||
""" | ||
|
||
var3: ClassVar[str] = "I am a class variable" # class variable | ||
|
||
def __init__(self, par1: int, par2: int): | ||
self.var1 = par1 # instance variables | ||
self.var2 = par2 | ||
|
||
def abc(a: int, c: List[int] = [1,2]) -> Any: | ||
laurenchilutti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
summary | ||
|
||
:param a: description | ||
:type a: int | ||
:param c: description, defaults to [1,2] | ||
:type c: list, optional | ||
:raises AssertionError: description | ||
:return: description | ||
:rtype: type | ||
|
||
.. note:: This is a note | ||
.. warning:: This is a warning | ||
""" | ||
|
||
#this is an example of type hinting a variable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type hinting for variables outside of method declarations- too much? |
||
child: bool | ||
if a < 18: | ||
child = True | ||
else: | ||
child = False | ||
|
||
if a > 10: | ||
raise AssertionError("a is more than 10") | ||
return c | ||
|
||
def func1(foo: str): | ||
laurenchilutti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
summary | ||
|
||
:param foo: description | ||
:type foo: str | ||
""" | ||
|
||
print(foo) | ||
``` |
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.
Uh oh!
There was an error while loading. Please reload this page.