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

Format docs #7821

Merged
merged 4 commits into from
Oct 29, 2022
Merged

Format docs #7821

merged 4 commits into from
Oct 29, 2022

Conversation

Cjkjvfnby
Copy link
Contributor

Describe your change:

Fix some warnings that would be raised by adding adding flake8-docstrings to the pre-commit hooks.

This PR is just to show the features of that tool.

There are two groups of checks.

Documentation

This looks like a good match with the repo guidelines. For classes and functions, there is an easy trick to use the leading underscore for names, then classes/functions won't be public, so you could document only what you need.

  • D100 Missing docstring in public module
  • D101 Missing docstring in public class
  • D104 Missing docstring in public package

Docstring formating

It might be a bit confusing for people since the summary does not have a lot of sense in the context of this repo. It will have the same words as in the file and function names and algorithm description is in the module docstring. Ignoring that line is not an option since there is a lot of code with doctests.

  • D205 1 blank line required between summary line and description
  • D400 First line should end with a period
  • D401 First line should be in imperative mood; try rephrasing
  • D403 First word of the first line should be properly capitalized
  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@algorithms-keeper algorithms-keeper bot added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed labels Oct 28, 2022
@Cjkjvfnby Cjkjvfnby mentioned this pull request Oct 28, 2022
1 task
physics/kinetic_energy.py Outdated Show resolved Hide resolved
sorts/merge_sort.py Outdated Show resolved Hide resolved
@CaedenPH
Copy link
Contributor

Perhaps what you could normalize would be all the different types of docstring params/returns, ie

"""
:param a: The first integer
:param b: The second integer
:return: The output
"""

and

"""
Parameters
------------
a: :class:`int`
    The first integer
b: :class:`int`
    The second integer

Returns
--------
:class:`int`
    The output

and

@params 
@returns 

etc...
However maybe it's just better to leave it to persona preference

Copy link
Contributor Author

@Cjkjvfnby Cjkjvfnby left a comment

Choose a reason for hiding this comment

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

...

@Cjkjvfnby
Copy link
Contributor Author

However maybe it's just better to leave it to persona preference

Since we don't build documentation for that code we could leave it as is.

80% of these params/returns could be eliminated by annotations and good variable names.

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 29, 2022
@cclauss cclauss merged commit cf08d9f into TheAlgorithms:master Oct 29, 2022
@cclauss
Copy link
Member

cclauss commented Oct 29, 2022

These all seems fine except maybe the one word sentence. ;-)

I think we should start to auto-generate docs using Sphinx plus sphinx-autodoc-typehints which I have used on other projects with great success. sphinx-autodoc-typehints does a great job of turning type hints into docs.

jjjake/internetarchive#524 (comment)

@Cjkjvfnby Cjkjvfnby deleted the format-docs branch October 29, 2022 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This PR modified some existing files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants