Commit 45c4cdb6 authored by Fox Danger Piacenti's avatar Fox Danger Piacenti
Browse files

docs: Switch to Mkdocs, update for recent refactor.

parent 919cf8ad
Loading
Loading
Loading
Loading
Loading
+5 −3
Changes for .gitignore: 5 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -7,9 +7,11 @@
.python-version
**/build/**
**/_build/**
providence/docs/assets/**
providence/docs/typedoc/**
providence/docs/providence_docs.egg-info/**
docs/docs/reference/**
docs/site/**
docs/mkdocs.yml
providence/docs/**
providence-redux/docs/**
**/dist/**
**/src/**/*.js
**/src/**/*.d.ts
+13 −7
Changes for .gitlab-ci.yml: 13 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@ tests-node18:
  image: node:18-alpine
  script:
    - apk add git make bash
    - make install_prereqs
    - cd providence && make install_prereqs
    - make test
    - cd ../providence-redux && make install_prereqs
    - make test

tests-node17:
@@ -25,7 +27,9 @@ tests-node17:
  image: node:17-alpine
  script:
    - apk add git make bash
    - make install_prereqs
    - cd providence && make install_prereqs
    - make test
    - cd ../providence-redux && make install_prereqs
    - make test

tests-node16:
@@ -33,7 +37,9 @@ tests-node16:
  image: node:16-alpine
  script:
    - apk add git make bash
    - make install_prereqs
    - cd providence && make install_prereqs
    - make test
    - cd ../providence-redux && make install_prereqs
    - make test

documentation:
@@ -41,10 +47,10 @@ documentation:
  image: nikolaik/python-nodejs:python3.8-nodejs18-alpine
  script:
    - apk add git make bash
    - cd providence && npm install
    - cd providence && pip install -r docs/requirements.txt
    - cd providence && pip install docs/
    - cd providence/docs && make html
    - pip install -r docs/requirements.txt
    - cd providence && npm install && cd ..
    - cd providence-redux && npm install && cd ..
    - cd docs && make build

npm_push:
  stage: deploy

docs/Makefile

0 → 100644
+33 −0
Changes for docs/Makefile: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
export SHELL := /usr/bin/env bash
export PROVIDENCE_PACKAGES := providence providence-redux

default: install_prereqs includes build

upgrade:
	pip-compile requirements.in

install_prereqs:
	pip install --upgrade pip pip-tools
	pip install -r requirements.txt

includes:
	@set -e
	# Clear out old compiled docs first.
	rm -rf docs/reference
	# Recreate the directory with its .gitkeep
	git checkout docs/reference
	for package in $${PROVIDENCE_PACKAGES[@]} ; do \
	  cd ../$$package && \
	  make generate_docs && \
	  mv docs/typedoc ../docs/docs/reference/$$package && \
	  cd ../docs && \
	  rm docs/reference/$$package/README.md && \
	  rm docs/reference/$$package/modules.md ; \
	done
	python update_mkdocs_yml.py

run: includes
	mkdocs serve

build: includes
	mkdocs build
+14 −22
Changes for docs/docs/concepts.md: 14 added lines, 22 removed lines.
Original line number Diff line number Diff line
Concepts
========

Providence has several concepts for simplifying your state management.

Modules
-------
## Modules

Providence automates the creation of pluggable modules for your preferred state manager. For example, in Redux it uses `Redux Dynamic Modules`_, and in Vuex, it uses the standard `dynamic module management feature <https://vuex.vuejs.org/guide/modules.html#dynamic-module-registration>`_. These modules have a combination of four definition sets:
Providence automates the creation of pluggable modules for your preferred state manager. For example, in Redux it uses [Redux Dynamic Modules](https://redux-dynamic-modules.js.org/), and in Pinia, it uses its standard [dynamic module management features](https://pinia.vuejs.org/cookbook/migration-vuex.html#Dynamic-Modules). These modules have a combination of four definition sets:

* **state**: The initial state of the module handed to the state manager.
* **mutations**: Functions which modify the state atomically. These are passed the current state as well as (optionally) an argument that instructs how the state is to be modified. For instance, you might have an `increment` function which automatically increases `state.value` by 1, or you might have a `setValue` function that takes a number as an argument.
* **tasks**: Async functions that may call any number of mutations (or other tasks) during their run. These functions are handed bound `store` object that contains a `commit` function, for committing mutations, a `dispatch` function for calling tasks, and a `state` object representing the current state. Like mutations, they may also be handed an additional argument of the function author's choosing.

Modules are run through the :js:attr:`Transformers.module` function in order to reformat their contents in a manner the target state manager will understand. **In most cases, you should not interact with modules directly, but through their** :ref:`Concepts:Controllers`.
Modules are run through the `[Transformers.module](configuration#module)` function in order to reformat their contents in a manner the target state manager will understand. **In most cases, you should not interact with modules directly, but through their** `[Controllers](#controllers)`.

To see an example of a factory function which generates a module, check out the :browse:`buildSingle </src/base/singles/index.ts>` source code.
To see an example of a factory function which generates a module, check out [buildSingle](reference/providence/functions/singles.buildSingle.md).

Controllers
-----------
## Controllers

Controllers are where the magic happens. They are objects that act as a proxy for all state management changes you may need. They allow you to treat changes to state (mostly) like normal TypeScript/JavaScript attributes and functions.

For instance, if a module has a `value` attribute on its state, you would need to implement a `setValue` mutation in order to change it. With the standard state management toolkits, this means taking the store and instructing it to commit 'setValue' for the particular module with a specified number. In some cases you completely forfeit type checking, and you have to remember what the name of the updating function is. It might look something like this:

.. code-block:: typescript

```typescript
store.commit('moduleName/setValue', 5)
```

...But with a controller, you do:

.. code-block:: typescript

```typescript
controller.value = 5
```

Much more idiomatic! The assignment will call `moduleName/setValue` in the background for you, keeping your logic free of the state manager's minutia.

Controllers have a `name` attribute used to uniquely identify them in their :ref:`Registry <Concepts:Registries>`. They have bound `commit` and `dispatch` functions that allow you to call their corresponding module mutations and tasks in a type-safe manner. However, in most cases, you won't need to call these directly. The getters, setters, and functions on a controller will call these for you.

The particular functions available in a controller depend on the module for which the controller was designed. See the relevant section (such as :ref:`Singles <module_types/singles:Singles>`) for more information.
Controllers have a `name` attribute used to uniquely identify them in their [Registry](concepts.md#registries). They have bound `commit` and `dispatch` functions that allow you to call their corresponding module mutations and tasks in a type-safe manner. However, in most cases, you won't need to call these directly. The getters, setters, and functions on a controller will call these for you.

Controllers are always passed through the :js:attr:`Transformers.controller` function, which should be provided by your state manager's plugin.
The particular functions available in a controller depend on the module for which the controller was designed. See the relevant section (such as [Singles](module_types/singles.md)) for more information.

.. _Redux Dynamic Modules: https://redux-dynamic-modules.js.org/
Controllers are always passed through the [Transformers.controller](configuration.md#controller) function, which should be provided by your state manager's plugin.

Registries
----------
## Registries

Registries keep track of controllers and determine whether or not it is time to load or unload a module from the store. Since dynamically generating a module with a controller can be computationally expensive, and several components may specify the need for a particular module, we only ever want to create one of them no matter how many components ask-- at least until all components that were interested have unloaded.

Registries are mostly an internal concept and you should not need to interact with them directly (much like with :ref:`Modules <Concepts:Modules>`), but they are useful to know about, as they help instrument much of the magic behind keeping track of controllers and ensuring sanity as far as your data store is concerned.
 No newline at end of file
Registries are mostly an internal concept and you should not need to interact with them directly (much like with [Modules](#modules), but they are useful to know about, as they help instrument much of the magic behind keeping track of controllers and ensuring sanity as far as your data store is concerned.
+17 −10
Changes for docs/docs/configuration.md: 17 added lines, 10 removed lines.
Original line number Diff line number Diff line
Configuration
=============
# Configuration

Providence's configuration options allow you to customize some of its automation. Each state management plugin comes with its own default settings for Providence that handle translating its functionality. Providence tries as much as possible to configure with sane defaults, but you will likely have to override at least a few settings, such as the :js:attr:`netCall <ProvidenceClient.netCall>` setting in the :js:class:`client <ProvidenceClient>`.

.. js:autoclass:: GlobalOptions
    :members:
{%
    include-markdown "./reference/providence/interfaces/types_GlobalOptions.GlobalOptions.md"
    heading-offset=1
%}

.. js:autoclass:: Transformers
    :members:
{%
    include-markdown "./reference/providence/interfaces/types_Transformers.Transformers.md"
    heading-offset=1
%}

.. js:autoclass:: ProvidenceClient
    :members:
{%
    include-markdown "./reference/providence/interfaces/types_ProvidenceClient.ProvidenceClient.md"
    heading-offset=1
%}

.. js:autoclass:: Drivers
    :members:
 No newline at end of file
{%
    include-markdown "./reference/providence/interfaces/types_Drivers.Drivers.md"
    heading-offset=1
%}
Loading