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 1 commit
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
Prev Previous commit
Next Next commit
Revert to sphinx
  • Loading branch information
josh-silvas committed Jun 23, 2021
commit 9885456560285fc1ee54efdd52131742b09be282
5 changes: 3 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
version: 2

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

python:
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DiffSync
<!--intro start-->

DiffSync is a utility library that can be used to compare and synchronize different datasets.

For example, it can be used to compare a list of devices from 2 inventory systems and, if required, synchronize them in either direction.
Expand All @@ -23,9 +23,9 @@ 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.
<!--intro end-->

# Getting started
<!--getting started start-->

To be able to properly compare different datasets, DiffSync relies on a shared data model that both systems must use.
Specifically, each system or dataset must provide a `DiffSync` "adapter" subclass, which in turn represents its dataset as instances of one or more `DiffSyncModel` data model classes.

Expand Down Expand Up @@ -151,4 +151,3 @@ class BackendA(DiffSync):
# The default DiffSync.sync_complete() method does nothing, but it's always a good habit to call super():
super().sync_complete(source, diff, flags, logger)
```
<!--getting started end-->
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
5 changes: 0 additions & 5 deletions docs/api_reference/diff/index.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/api_reference/diffsync.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/api_reference/diffsyncmodel.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/api_reference/enum/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/api_reference/exceptions/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/api_reference/helpers/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/api_reference/logging/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/api_reference/utils/index.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/examples/example1.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/examples/example2.md

This file was deleted.

19 changes: 0 additions & 19 deletions docs/extra.css

This file was deleted.

8 changes: 0 additions & 8 deletions docs/getting_started.md

This file was deleted.

8 changes: 0 additions & 8 deletions docs/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/license.md

This file was deleted.

56 changes: 56 additions & 0 deletions docs/source/api/diffsync.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
API Reference
=============

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


diffsync.diff
-------------

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

diffsync.enum
-------------

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

diffsync.exceptions
-------------------

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

diffsync.helpers
----------------

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

diffsync.logging
----------------

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

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(["-MTf", "-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
Loading