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

Create, publish public API documentation on readthedocs.io #98

Merged
merged 62 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
6f4b13f
Add sphinx dependencies
vinceatbluelabs Jun 29, 2020
61a790f
Add initial docs source
vinceatbluelabs Jun 29, 2020
3abfab2
Add records_mover to toctree
vinceatbluelabs Jun 29, 2020
be2a095
Autogenerate source apidoc rst files
vinceatbluelabs Jun 29, 2020
a74c47b
Allow running after already cleared
vinceatbluelabs Jun 29, 2020
c444f3c
Deal with issue during apidocs import
vinceatbluelabs Jun 29, 2020
52197e7
Revert automatic generation - readthedocs.io does not support
vinceatbluelabs Jun 29, 2020
98812c5
Drop submodules, include special-members
vinceatbluelabs Jun 30, 2020
58d3f95
Document public API of records_mover.airflow
vinceatbluelabs Jun 30, 2020
b18873a
Move GoogleCloudCredentialsHook to airflow.hooks
vinceatbluelabs Jun 30, 2020
66ce59c
Document public API of records_mover.airflow
vinceatbluelabs Jun 30, 2020
0d1f78d
Trim things which are not part of public API
vinceatbluelabs Jun 30, 2020
24bc882
Exclude RecordsSchema from public documentation for now
vinceatbluelabs Jul 1, 2020
63b437f
Fix formatting
vinceatbluelabs Jul 1, 2020
0f63d74
Fix some documentation formatting
vinceatbluelabs Jul 1, 2020
dfd93ae
Merge remote-tracking branch 'origin/master' into publish_docs
vinceatbluelabs Jul 1, 2020
9b1995a
Format sources factory
vinceatbluelabs Jul 2, 2020
7131ad1
Tweak records target documentation
vinceatbluelabs Jul 2, 2020
5872e52
Tweak records target documentation
vinceatbluelabs Jul 2, 2020
bf783d5
Clear out records submodule documentation
vinceatbluelabs Jul 2, 2020
a563aa3
Use get_args() instead of VALID_VARIANTS
vinceatbluelabs Jul 6, 2020
fd978cb
Document more things
vinceatbluelabs Jul 6, 2020
cb018a6
Create docs extra
vinceatbluelabs Jul 6, 2020
d25f27a
Create docs extra
vinceatbluelabs Jul 6, 2020
1979dd9
Fix syntax
vinceatbluelabs Jul 6, 2020
40d5958
Create docs extra
vinceatbluelabs Jul 6, 2020
280a981
Create docs extra
vinceatbluelabs Jul 6, 2020
23e89f9
Create docs extra
vinceatbluelabs Jul 6, 2020
7fe9510
Fix missing TOCs, remove RecordsSchema
vinceatbluelabs Jul 6, 2020
20411b8
Have Sphinx fail on warning
vinceatbluelabs Jul 6, 2020
f24165e
Add _static directory
vinceatbluelabs Jul 6, 2020
de23e61
Fix docstring
vinceatbluelabs Jul 6, 2020
71e3e63
Delete unreferenced file
vinceatbluelabs Jul 6, 2020
82bb2fa
Drop undocumented packages
vinceatbluelabs Jul 7, 2020
4708dac
Bring in version automatically
vinceatbluelabs Jul 7, 2020
0fd2a49
Add pointers to documentation in README
vinceatbluelabs Jul 7, 2020
52f9c8e
Update copyright
vinceatbluelabs Jul 7, 2020
66ad7b3
Document documentation generation; improve description of public vs
vinceatbluelabs Jul 7, 2020
413f5ac
Document parameter types in description of parameter, not in function…
vinceatbluelabs Jul 7, 2020
e6cf90f
Drop undocumented package
vinceatbluelabs Jul 7, 2020
73693ff
Drop blank line in docstring
vinceatbluelabs Jul 7, 2020
404ef14
Add documentation status
vinceatbluelabs Jul 7, 2020
7ea2482
Fix up text of docstrings
vinceatbluelabs Jul 8, 2020
7f246f5
Set autodoc_member_order = 'bysource'
vinceatbluelabs Jul 8, 2020
9871f46
Exclude RecordsFormatType
vinceatbluelabs Jul 8, 2020
f5ebe0d
Document records_schema as not for external use
vinceatbluelabs Jul 8, 2020
bfc1e54
Drop creds argument
vinceatbluelabs Jul 8, 2020
a3f6819
Merge remote-tracking branch 'origin/master' into publish_docs
vinceatbluelabs Jul 8, 2020
3ca322d
Resolve flake8 issues
vinceatbluelabs Jul 8, 2020
53a9897
Bump bigfiles
vinceatbluelabs Jul 8, 2020
6d1fc2f
Fix flake8 issues
vinceatbluelabs Jul 8, 2020
80dbd1d
Ratchet
vinceatbluelabs Jul 8, 2020
7eb2960
Fix mypy errors
vinceatbluelabs Jul 8, 2020
e16b177
Ratchet coverage
vinceatbluelabs Jul 8, 2020
74a4838
Fix tests around DelimitedVariant docs
vinceatbluelabs Jul 8, 2020
8bd46bb
Unrachet
vinceatbluelabs Jul 8, 2020
788a9b3
Ratchet
vinceatbluelabs Jul 8, 2020
9ec6984
Add trailing newline
vinceatbluelabs Jul 9, 2020
93f672e
Fix doc drift
vinceatbluelabs Jul 9, 2020
e513abc
Clarify comment
vinceatbluelabs Jul 9, 2020
2ba42e4
Clarify why docstring is missing
vinceatbluelabs Jul 9, 2020
37c2b62
Clarify doc generation
vinceatbluelabs Jul 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

python:
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- docs

sphinx:
fail_on_warning: true
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
src="https://raw.githubusercontent.com/bluelabsio/records-mover/master/docs/records-mover-horizontal.png"
alt="Records Mover">

[![Documentation Status](https://readthedocs.org/projects/records-mover/badge/?version=publish_docs)](https://records-mover.readthedocs.io/en/publish_docs/?badge=latest)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Update readthedocs URLs back to master branch


Records mover is a command-line tool and Python library you can
use to move relational data from one place to another.

Expand Down Expand Up @@ -92,8 +94,9 @@ results = move(source, target)
```

When moving data, the sources supported can be found
[here](./records_mover/records/sources/factory.py), and the
targets supported can be found [here](./records_mover/records/targets/factory.py).
[here](https://records-mover.readthedocs.io/en/publish_docs/records_mover.records.sources.html),
and the targets supported can be found
[here](https://records-mover.readthedocs.io/en/publish_docs/records_mover.records.targets.html).

## Advanced Python library use

Expand Down Expand Up @@ -138,3 +141,15 @@ target = targets.table(schema_name='myschema',
db_engine=db_engine)
results = move(source, target)
```

## Python library API documentation

You can can find more API documentation
[here](https://records-mover.readthedocs.io/en/publish_docs/index.html).
In particular, note:

* [Session() constructor](https://records-mover.readthedocs.io/en/publish_docs/records_mover.html#records_mover.Session.__init__)
* [sources factory methods](https://records-mover.readthedocs.io/en/publish_docs/records_mover.records.sources.html)
* [targets factory methods](https://records-mover.readthedocs.io/en/publish_docs/records_mover.records.targets.html)
* [move() method](https://records-mover.readthedocs.io/en/publish_docs/records_mover.records.html#records_mover.records.move)
* [BaseRecordsFormat](https://records-mover.readthedocs.io/en/publish_docs/records_mover.records.html#records_mover.records.base_records_format.BaseRecordsFormat)
2 changes: 1 addition & 1 deletion deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pip3 install --upgrade pip
# It's nice to unit test, integration test, and run the CLI in
# a development pyenv.
#
pip3 install -r requirements.txt -e '.[unittest,itest,cli,typecheck]'
pip3 install -r requirements.txt -e '.[unittest,itest,cli,typecheck,docs]'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this extra, you can run 'make docs' in the docs/ directory and generate things locally.

18 changes: 16 additions & 2 deletions docs/MAINT.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Packages inside include:
things that haven't grown enough mass to be exported into their own
package.

Things either labeled private with a prefix of `_` aren't stable
interfaces - they can change rapidly.
Things either labeled private, not in `__all__`, undocumented or with
a prefix of `_` aren't stable interfaces - they can change rapidly.

If you need access to another function/class, please submit an issue
or a PR make it public. That PR is a good opportunity to talk about
Expand Down Expand Up @@ -75,6 +75,20 @@ To run the same suite with mover itself in a Docker image:
Try expanding your Docker for Mac memory size to 8G. Vertica is
memory intensive, even under Docker.

### Documentation

API reference documentation is pushed up to
[readthedocs](https://records-mover.readthedocs.io/en/publish_docs/) by a
GitHub webhook.

To create docs, run this from the `docs/` directory:

* `make html`

To view docs:

* `open build/html/index.html`

### Manual integration testing

There's also a manual records schema JSON functionality
Expand Down
23 changes: 23 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?= -W
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

apidocs:
@sphinx-apidoc -o ./source ../records_mover

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Empty file added docs/source/_static/.gitkeep
Empty file.
75 changes: 75 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
import records_mover # noqa


# -- Project information -----------------------------------------------------

project = 'records-mover'
copyright = '2020 BlueLabs Analytics, Inc.'
author = 'Vince Broz'

# The full version, including alpha/beta/rc tags
release = records_mover.version.__version__


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

#
# This value selects if automatically documented members are sorted
# alphabetical (value 'alphabetical'), by member type (value
# 'groupwise') or by source order (value 'bysource'). The default is
# alphabetical.
#
# records mover picks 'groupwise' so that enums appear in the order
# listed in the source code, which can reflect a natural order.
#
autodoc_member_order = 'bysource'

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# -- Options for type generation ---------------------------------------------

#
# Document parameter types in description of parameter, not in
# function signature part of documentation.
#
autodoc_typehints = 'description'
21 changes: 21 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. records-mover documentation master file, created by
sphinx-quickstart on Fri Jun 26 11:46:58 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to records-mover's documentation!
=========================================

.. toctree::
:maxdepth: 2
:caption: Contents:

records_mover


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was sort of expecting documentation generation to be entirely driven by docstring comments, but the Sphinx toolkit seems to be a tad more rustic than that. As a result, these .rst files contain:

  • any tweaks that need to be done to the default generation strategy (you'll see some examples later on)
  • lists of the specific public API that will be documented
  • any module-level documentation needed, which doesn't seem to be brought in at all (I generally chose to leave this out and preferred documenting things at the class level)

16 changes: 16 additions & 0 deletions docs/source/records_mover.airflow.hooks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
records\_mover.airflow.hooks package
====================================

Module contents
---------------

.. comment:
SqlAlchemyDbHook.validate_and_prepare_target_directory is something
I'd like to explore removing and promoting to something
non-Airflow-related, so let's not include it in the docs and leave
'undoc-members' out

.. automodule:: records_mover.airflow.hooks
:members:
:show-inheritance:
:special-members: __init__
10 changes: 10 additions & 0 deletions docs/source/records_mover.airflow.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
records\_mover.airflow package
==============================

Subpackages
-----------

.. toctree::
:maxdepth: 4

records_mover.airflow.hooks
82 changes: 82 additions & 0 deletions docs/source/records_mover.records.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
records\_mover.records package
==============================

Subpackages
-----------

.. toctree::
:maxdepth: 4

records_mover.records.sources
records_mover.records.targets
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the 'documenting only the public API' comes from judicious exclusion of things from these subpackage lists.


Submodules
----------

records\_mover.records.base\_records\_format module
---------------------------------------------------

.. autoclass:: records_mover.records.base_records_format.BaseRecordsFormat
:members:
:show-inheritance:
:special-members: __init__
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the time I chose to bring up key public API classes into the __all__ of records_mover or record_mover.records, which also ensures that Sphinx will document it there. I then left out the implementation module where it was defined from Sphinx so it didn't get double-documented, and so that we can move things around without folks doing deep 'import' statements.

This is a case where I couldn't get away with that, as Sphinx documented it as a base class of DelimitedRecordsFormat and ParquetRecordsFormat--leaving this out broke the link. I couldn't figure how to convince it to do otherwise.


Module contents
---------------

.. comment:

I exclude PartialRecordsHints entirely below because Sphinx doesn't
yet support TypedDict types that have hyphens as part of the keys.
Example error on 'make html':

WARNING: invalid signature for autoinstanceattribute
('records_mover.records::PartialRecordsHints.header-row')

I exclude RecordsSchema as we haven't defined yet exactly what
public API to export.

https://github.com/bluelabsio/records-mover/issues/97

I exclude RecordsFormat as it's generally an internal factory
method useful when reading undifferentiated JSON files - a general
user ought to be able to select their records format in advance and
use the correct subclass.

I exclude UntypedRecordsHints and RecordsFormatType as it hasn't
been used in any other part of the public interface.

I exclude DelimitedVariant as there's no way to specify a
docstring, so I add out-of-band documentation below.

.. automodule:: records_mover.records
:members:
:undoc-members:
:show-inheritance:
:exclude-members: DelimitedRecordsFormat, ParquetRecordsFormat, ProcessingInstructions, PartialRecordsHints, RecordsSchema, RecordsFormat, UntypedRecordsHints, RecordsFormatType, DelimitedVariant

.. autoclass:: records_mover.records.DelimitedRecordsFormat
:undoc-members:
:show-inheritance:
:special-members: __init__

.. autoclass:: records_mover.records.ParquetRecordsFormat
:undoc-members:
:show-inheritance:
:special-members: __init__

.. autoclass:: records_mover.records.ProcessingInstructions
:undoc-members:
:show-inheritance:
:special-members: __init__

.. py:data:: DelimitedVariant
:module: records_mover.records

Valid string values for the variant of a delimited records format.
Variants specify a default set of parsing hints for how the delimited
file is formatted. See the `records format specification
<https://github.com/bluelabsio/records-mover/blob/master/docs/RECORDS_SPEC.md>`_
for semantics of each.

alias of Literal[dumb, csv, bigquery, bluelabs, vertica]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sadly, there's no way to assign a docstring to:

DelimitedVariant = Literal[dumb, csv, bigquery, bluelabs, vertica]

...so I had to do it out-of-band here.

10 changes: 10 additions & 0 deletions docs/source/records_mover.records.sources.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
records\_mover.records.sources package
======================================

Module contents
---------------

.. automodule:: records_mover.records.sources
:members:
:undoc-members:
:show-inheritance:
10 changes: 10 additions & 0 deletions docs/source/records_mover.records.targets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
records\_mover.records.targets package
======================================

Module contents
---------------

.. automodule:: records_mover.records.targets
:members:
:undoc-members:
:show-inheritance:
26 changes: 26 additions & 0 deletions docs/source/records_mover.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
records\_mover package
======================

Subpackages
-----------

.. toctree::
:maxdepth: 4

records_mover.airflow
records_mover.records

Module contents
---------------

.. automodule:: records_mover
:members:
:undoc-members:
:show-inheritance:
:exclude-members: Session

.. autoclass:: records_mover.Session
:members: records, set_stream_logging, get_db_engine, get_default_db_engine
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I documented only specific methods here. In particular I didn't yet document the Creds hierarchy - it seemed like a whole different can of worms to lock down at this point. As a result, the methods needed to do google sheets work aren't documented in Sphinx yet - I dropped a post-1.0 backlog item to deal with that.

:undoc-members:
:show-inheritance:
:special-members: __init__
2 changes: 1 addition & 1 deletion metrics/bigfiles_high_water_mark
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1002
1019
Copy link
Contributor Author

Choose a reason for hiding this comment

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

setup.py has more extras for documentation generation.

2 changes: 1 addition & 1 deletion metrics/coverage_high_water_mark
Original file line number Diff line number Diff line change
@@ -1 +1 @@
93.700
93.7100
2 changes: 1 addition & 1 deletion metrics/flake8_high_water_mark
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174
170
2 changes: 1 addition & 1 deletion metrics/mypy_high_water_mark
Original file line number Diff line number Diff line change
@@ -1 +1 @@
92.2800
92.3100
Loading