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

WIP: Read the docs #90

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

ross-spencer
Copy link
Contributor

@ross-spencer ross-spencer commented Nov 13, 2020

This commit is starting to create a framework for creating the necessary documentation for both developers, and users. I wanted to explore what we can do with standard tooling which we use in other projects, and share some of that learning with the team, although they may already have this know-how so it might just be for myself.

Connected to #33 which might be developed out of this effort, but it might be better suited under a documentation effort.

To preview:

  • Clone this repo.
  • Open the docs/_build/html directory in your favorite flavor of web-browser.
  • A non-css preview here <-- it doesn't look so great!

To use:

  • Install requirements via pip install -r requirements/dev.txt
  • Use the Makefile in the docs folder, e.g. make html once changes have been made to code.

How I created this documentation so far:

  1. Made a docs directory.
  2. Then ran sphinx-quickstart to generate a layout. Default values were selected
    unless other values were needed.
  3. Then modified a few more values based on this sheet; https://medium.com/better-programming/auto-documenting-a-python-project-using-sphinx-8878f9ddc6e9
    and projects like a3m and mets-reader-writer for which we already have some
    documentation.
  4. Then we can run sphinx-apidoc. This generates our documentation!
    sphinx-apidoc -o ../docs ../AIPscan
  5. I needed to add 'modules' as a line to index.rst.
  6. Can then customize the index.rst which is only updated once. Unless it is
    recreated (source control). And we can add links to other modules and also
    annotate some of the bits and pieces that we want to drape people's
    attention to.
  7. Can add other custom rst files, for example, I added overview.rst.
  8. Changes to the documentation in the code can be added to the docs via
    make html.

TODO:

  • We can add a task to CI to test for good doc formatting in code.
  • Decide what the minimal level of information is we want for AIPscan via these docs.
  • Look for formatting linting tools, e.g. Google style, and decide what we'd like.
  • Add to readthedocs.
  • Anything else?

Where this takes us...

Python doesn't seem to be as well suited to this as other languages, i.e. it's not as integrated, and pydoc can be a tad flaky, but one nice impact of documentation from code, like this, and why it is connected to #33 is that we can improve the quality and consistency of our docstrings by inspecting them through the docs.

For example:

An example of a simple module summary using a module docstring:

image

An example of nice function level documentation from Tessa:

image

A much more basic one from myself, which might not be the style we adopt moving forward:

image

We can become more fluent with how we format our docstrings which we use to decorate our code. One small example based on Tessa's approach might be to then add pre-formatted text for code within strings, e.g. for the dict reference, and how the dict is used, e.g. somedict[somevalue].

tw4l and others added 18 commits November 2, 2020 15:16
This commit adds module-wide `app_instance` fixtures which are used to
provide application context to tests under the Application Factory
pattern, as well as a test that demonstrates how to test database state
using our test config with in-memory test database.

Due to how pytest discovers fixtures, removing the duplication of the
fixtures as defined in conftest modules would require re-organizing our
tests into a single AIPscan.tests directory.
This commit adds the application context to tests via the app_instance
fixture so that it's not necessary to do so explicitly within tests and
adds some post-test cleanup.
This commit replaces Blueprint-specific conftest modules with a single
one that can be used across the project.

It also makes use of the app.app_context context manager so that we do
not need to push and pop the app context manually.
This commit moves the Application Factory into AIPscan's __init__
module. This seems to be common practice, reduces the number of new
modules added in this work, and provides the potential down the line
to call the Application Factory directly from gunicorn without the need
for a wsgi.py entrypoint should we choose to do so.
NB. This is a hammer-nail solution, we'll want to take this a
different direction, e.g. inheriting from base requirements first,
and adding dev reqs on-top, before merging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants