Skip to content

#33 rtd documentation #59

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

Merged
merged 22 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
558f58c
Adds RTD files and dependencies
josh-silvas Jun 21, 2021
1927dd8
Adds RTD requirements
josh-silvas Jun 21, 2021
f5f9357
Adds sphinx callback for RTD to run apidoc generator.
josh-silvas Jun 21, 2021
02e60f4
Update getting_started/index.rst line lengh
josh-silvas Jun 21, 2021
888c12e
Updates docs/conf.py with correct root directory.
josh-silvas Jun 21, 2021
3ec327e
Adds import of diffsync library
josh-silvas Jun 21, 2021
66919a9
Updates path imports
josh-silvas Jun 21, 2021
8bf41b3
Updates doc requirements.txt
josh-silvas Jun 21, 2021
77eb691
Add invoke commands for documentation.
josh-silvas Jun 22, 2021
ef16cae
Adds small changes for tests.
josh-silvas Jun 22, 2021
dc9f57b
Move doc requirements into pyproject.toml
josh-silvas Jun 22, 2021
2691199
Adds toml to optional poetry install
josh-silvas Jun 22, 2021
1b7e07e
Updates toml version
josh-silvas Jun 22, 2021
665dd0d
Update example titles.
josh-silvas Jun 22, 2021
4edb610
Update documentation and homepage reference in pyproject.toml to poin…
josh-silvas Jun 22, 2021
63865d0
Update docs/source/conf.py
josh-silvas Jun 22, 2021
65e19ca
Convert from sphinx to mkdocs as per the standard.
josh-silvas Jun 23, 2021
3960411
Updates poetry.extras for the docs
josh-silvas Jun 23, 2021
09fac74
Adds doc dependencies in as optional
josh-silvas Jun 23, 2021
9885456
Revert to sphinx
josh-silvas Jun 23, 2021
811af15
Fixes separate pages for api reference.
josh-silvas Jun 23, 2021
ca2a51e
Removes api_doc invoke function as this is now handled via a sphinx c…
josh-silvas Jun 23, 2021
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,6 @@ fabric.properties
.vscode/*

*.code-workspace

## Sphinx Documentation ##
docs/build
15 changes: 15 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
version: 2

sphinx:
builder: "html"
configuration: "docs/source/conf.py"
fail_on_warning: false

python:
version: 3.7
install:
- method: "pip"
path: "."
extra_requirements:
- "docs"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A.sync_from(B)
A.sync_to(B)
```

You may wish to peruse the [`diffsync` GitHub topic](https://github.com/topics/diffsync) for examples of projects using this library.
You may wish to peruse the `diffsync` [GitHub topic](https://github.com/topics/diffsync) for examples of projects using this library.

# Getting started

Expand Down
2 changes: 1 addition & 1 deletion diffsync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DiffSyncModel(BaseModel):
This class has several underscore-prefixed class variables that subclasses should set as desired; see below.

NOTE: The groupings _identifiers, _attributes, and _children are mutually exclusive; any given field name can
be included in **at most** one of these three tuples.
be included in **at most** one of these three tuples.
"""

_modelname: ClassVar[str] = "diffsyncmodel"
Expand Down
7 changes: 7 additions & 0 deletions docs/source/api/diffsync.diff.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diffsync.diff
=============

.. automodule:: diffsync.diff
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/api/diffsync.enum.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diffsync.enum
=============

.. automodule:: diffsync.enum
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/api/diffsync.exceptions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diffsync.exceptions
===================

.. automodule:: diffsync.exceptions
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/api/diffsync.helpers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diffsync.helpers
================

.. automodule:: diffsync.helpers
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/api/diffsync.logging.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diffsync.logging
================

.. automodule:: diffsync.logging
:members:
:undoc-members:
:show-inheritance:
18 changes: 18 additions & 0 deletions docs/source/api/diffsync.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
API Reference
=============

.. automodule:: diffsync
:members:
:undoc-members:
:show-inheritance:


.. toctree::
:maxdepth: 4

diffsync.diff
diffsync.enum
diffsync.exceptions
diffsync.helpers
diffsync.logging
diffsync.utils
7 changes: 7 additions & 0 deletions docs/source/api/diffsync.utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diffsync.utils
==============

.. automodule:: diffsync.utils
:members:
:undoc-members:
:show-inheritance:
99 changes: 99 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"""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.
# pylint: disable=W,C,R
import os
import sys

from pathlib import Path
from sphinx.ext.apidoc import main

try:
import toml
except ImportError:
sys.exit("Please make sure to `pip install toml` or enable the Poetry shell and run `poetry install`.")

# -- Variable setup --------------------------------------------------------------

ROOT_DIR = Path(__file__).parent.parent.parent
CURR_DIR = f"{ROOT_DIR}/docs/source"
PYPROJECT_CONFIG = toml.load(f"{ROOT_DIR}/pyproject.toml")
TOOL_CONFIG = PYPROJECT_CONFIG["tool"]["poetry"]

# Inserts the diffsync library into the path. This is needed for RTD env to find the
# library needed for autodocs.
sys.path.insert(0, os.path.abspath("../.."))

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

project = TOOL_CONFIG["name"]
copyright = f"2020-2021, {','.join(TOOL_CONFIG['authors'])}"
author = ",".join(TOOL_CONFIG["authors"])

# The full version, including alpha/beta/rc tags
release = TOOL_CONFIG["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", "sphinx.ext.napoleon", "m2r2"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm familiar with autodoc and napoleon - for my information, what is m2r2 and what does it provide?


autodoc_default_options = {
"members": True,
"show-inheritance": True,
"special-members": "__init__",
"undoc-members": True,
}


# 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 = ["_build", "Thumbs.db", ".DS_Store"]


# -- 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"]


def remove_module_docstring(app, what, name, obj, options, lines):
"""Removes copyright heading on modules to prevent unneeded reference in the API documentation."""
if what == "module":
# At the module level, remove everything except the first line containing a summary of the module. All
# lines that follow are copyright notices.
del lines[1:]


def run_apidoc(_):
"""Adds the sphinx-apidoc command as a callback during the build process."""
main(["-MTfe", "-t", f"{CURR_DIR}/template/api", "-o", f"{CURR_DIR}/api", f"{ROOT_DIR}/{TOOL_CONFIG['name']}"])


def setup(app):
"""Registers the callbacks to be called when the event is emitted."""
app.connect("builder-inited", run_apidoc)
app.connect("autodoc-process-docstring", remove_module_docstring)
7 changes: 7 additions & 0 deletions docs/source/examples/01-multiple-data-sources.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
****************************
Using Multiple Data Sources
****************************

.. mdinclude:: ../../../examples/example1/README.md
:start-line: 2
:end-line: 67
7 changes: 7 additions & 0 deletions docs/source/examples/02-callback-function.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
******************
Callback Function
******************

.. mdinclude:: ../../../examples/example2/README.md
:start-line: 2
:end-line: 44
9 changes: 9 additions & 0 deletions docs/source/examples/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
############
Examples
############

.. toctree::
:maxdepth: 2

01-multiple-data-sources
02-callback-function
7 changes: 7 additions & 0 deletions docs/source/getting_started/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
###############
Getting Started
###############

.. mdinclude:: ../../../README.md
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor rendering error here as well - note that the last two paragraphs are indented as if they're part of the bulleted list:

image

:start-line: 28
:end-line: 153
20 changes: 20 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Welcome to DiffSync's documentation!
====================================

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

overview/index
getting_started/index
examples/index
api/diffsync
license/index



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

* :ref:`genindex`
* :ref:`modindex`
5 changes: 5 additions & 0 deletions docs/source/license/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
############
License
############

.. mdinclude:: ../../../LICENSE
7 changes: 7 additions & 0 deletions docs/source/overview/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*********
Overview
*********

.. mdinclude:: ../../../README.md
:start-line: 2
:end-line: 25
62 changes: 62 additions & 0 deletions docs/source/static/schema-page.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
body {
font-family: 'Fira Sans', 'Noto Sans', 'Source Sans Pro', 'Segoe UI', Roboto, 'Lucida Sans Unicode', 'Lucida Grande', 'DejaVu Sans', sans-serif;
}
@media (min-width: 60em) {
body {
display: flex;
flex-direction: row;
}
}
#jschemer-nav {
min-width: 15rem;
padding: 1em;
}
.jschemer-schema {
border: 0.05em solid #CCC;
border-radius: 0.25em;
margin: 0.5em;
max-width: 60em;
padding: 1em;
}
.jschemer-schema code,
.jschemer-schema pre {
background-color: rgba(27, 31, 35, 0.05);
border-radius: 0.1em;
font-size: 85%;
line-height: 1.5;
}
.jschemer-schema pre {
padding: 1em 0.5em;
}
.jschemer-schema code {
display: inline;
font-family: 'Fira Mono', 'Noto Mono', 'Source Code Pro', Consolas, 'Roboto Mono', 'Lucida Console', Monaco, 'DejaVu Sans Mono', monospace;
font-size: 85%;
line-height: inherit;
padding: 0.2em 0.4em;
word-wrap: normal;
}
.jschemer-schema pre > code {
background-color: transparent;
padding: 0;
}
.jschemer-schema h1 {
display: inline;
font-size: 1.5em;
vertical-align: middle;
}
.jschemer-schema h1 code::before {
content: '"';
}
.jschemer-schema h1 code::after {
content: '"';
}
.jschemer-schema h2 {
font-size: 1em;
}
main > .jschemer-schema > details > summary > h1 {
font-size: 2em;
}
main ul {
list-style: disc;
}
13 changes: 13 additions & 0 deletions docs/source/static/theme_overrides.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* override table width restrictions */
@media screen and (min-width: 767px) {

.wy-table-responsive table td {
/* !important prevents the common CSS stylesheets from overriding
this as on RTD they are loaded after this stylesheet */
white-space: normal !important;
}

.wy-table-responsive {
overflow: visible !important;
}
}
9 changes: 9 additions & 0 deletions docs/source/template/api/module.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{%- if show_headings %}
{{- basename | e | heading }}

{% endif -%}
.. automodule:: {{ qualname }}
{%- for option in automodule_options %}
:{{ option }}:
{%- endfor %}

Loading