Closed aldraco closed 2 years ago
We've added basic doctstrings to the basics
exercise (see issue exercism/v3#1999 and related PR). Propose we change this into a concept exercise around docstring and doctest best practices, and formatting for documentation generator tools such as Sphinx. @cmccandless - thoughts?
Propose we change this into a concept exercise around docstring and doctest best practices
Agreed
and formatting for documentation generator tools such as Sphinx.
I think perhaps doctest and Sphinx are worth a mention in the after.md of such an exercise.
Putting this on hold until we can get the issue updated with new specs.
This issue has been automatically marked as abandoned 🏚
because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I don't like you stalebot
. Not even a little.
This needs more detail and a write-up under the new issue template. Closing for now until we can get to that.
This issue describes how to implement the
docstrings
concept exercise for the Python track.Getting started
Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
Please also watch the following video:
Goal
This exercise should demonstrate and motivate the proper use of docstrings in Python, according to PEP 257.
Learning objectives
__doc__
dunder / magic attributeIdeally, this exercise would have a pre-written module, which contains a class, which has several methods on it. The student should write the documentation for
Since this is an automated exercise, there isn't a lot of room for discussion of the content of the docstrings, but we can check for its existence, formatting (a blank line between summary and paragraph, for example) and an approximate length that we feel is appropriate.
Out of scope
The examples should probably be in reST since it's fairly prevalent, but the formatting here is more related to a specific implementation of a documentation parser, not a generalized understanding of what docstrings are and how they should be used.
Mentioning that return types can/should be documented is a good idea, but not necessary for the scope of this exercise, since it can also be covered more thoroughly by a
typing
exercise or similar.Concepts
docstrings
Prerequisites
comments
functions
methods
classes
modules
Resources to refer to
https://www.python.org/dev/peps/pep-0257/ https://www.python.org/dev/peps/pep-0287/
https://docs.python-guide.org/writing/documentation/#docstrings-and-magic https://docs.python-guide.org/writing/documentation/#sphinx
Hints
The following should be explicilty tested for:
After
Now is a good time to think about introducing the student to the magic (and usefulness) of automated documentation generators, or exposing them to prevalent examples of them in the Python community.
Representer
?
Analyzer
?
Implementing
Tests should be written using
unittest.TestCase
, and the test file nameddocstrings_test.py
.Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue.