From 8ab565e25ae31cfcea070a4a3eed2d3441a6d79d Mon Sep 17 00:00:00 2001 From: Dennis Scheiba Date: Tue, 5 Dec 2023 01:02:06 +0100 Subject: [PATCH 1/2] add tutorial --- caster-back/gencaster/schema.py | 2 + caster-back/story_graph/__init__.py | 2 +- caster-back/story_graph/models.py | 25 ++++ caster-back/stream/__init__.py | 2 +- docs/Makefile | 6 +- docs/_static/custom.css | 12 ++ docs/back/api/index.rst | 10 -- docs/back/{api => }/gencaster.rst | 0 docs/back/graphql.rst | 13 --- docs/back/index.rst | 11 +- docs/back/{api => }/story_graph.rst | 0 docs/back/{api => }/stream.rst | 0 docs/conf.py | 2 + docs/deployment.rst | 4 +- docs/editor.rst | 12 +- docs/front.rst | 15 --- docs/glossary.rst | 145 +++++++++++++++++++++++ docs/index.rst | 26 ++--- docs/quickstart.rst | 6 - docs/services.rst | 40 ++++++- docs/sound.rst | 4 - docs/story_graph.rst | 105 ----------------- docs/tutorial.rst | 47 ++++++++ docs/tutorial/01-story_graph.rst | 130 +++++++++++++++++++++ docs/tutorial/02-listening.rst | 43 +++++++ docs/tutorial/03-connecting-nodes.rst | 123 ++++++++++++++++++++ docs/tutorial/04-live-editing.rst | 42 +++++++ docs/tutorial/05-speaking.rst | 87 ++++++++++++++ docs/tutorial/06-interaction.rst | 150 ++++++++++++++++++++++++ docs/tutorial/07-node_doors.rst | 161 ++++++++++++++++++++++++++ docs/tutorial/08-debugging.rst | 23 ++++ 31 files changed, 1060 insertions(+), 188 deletions(-) delete mode 100644 docs/back/api/index.rst rename docs/back/{api => }/gencaster.rst (100%) delete mode 100644 docs/back/graphql.rst rename docs/back/{api => }/story_graph.rst (100%) rename docs/back/{api => }/stream.rst (100%) delete mode 100644 docs/front.rst create mode 100644 docs/glossary.rst delete mode 100644 docs/quickstart.rst delete mode 100644 docs/sound.rst delete mode 100644 docs/story_graph.rst create mode 100644 docs/tutorial.rst create mode 100644 docs/tutorial/01-story_graph.rst create mode 100644 docs/tutorial/02-listening.rst create mode 100644 docs/tutorial/03-connecting-nodes.rst create mode 100644 docs/tutorial/04-live-editing.rst create mode 100644 docs/tutorial/05-speaking.rst create mode 100644 docs/tutorial/06-interaction.rst create mode 100644 docs/tutorial/07-node_doors.rst create mode 100644 docs/tutorial/08-debugging.rst diff --git a/caster-back/gencaster/schema.py b/caster-back/gencaster/schema.py index 6379b054..1e434429 100644 --- a/caster-back/gencaster/schema.py +++ b/caster-back/gencaster/schema.py @@ -1,4 +1,6 @@ """ +.. _schema: + Schema ====== diff --git a/caster-back/story_graph/__init__.py b/caster-back/story_graph/__init__.py index b2a8b272..0f863109 100644 --- a/caster-back/story_graph/__init__.py +++ b/caster-back/story_graph/__init__.py @@ -10,7 +10,7 @@ Graph ----- -.. figure:: ../../graphs/story_graph.png +.. figure:: ../graphs/story_graph.svg Model graph for the story graph app. diff --git a/caster-back/story_graph/models.py b/caster-back/story_graph/models.py index 5816eb96..a37aa428 100644 --- a/caster-back/story_graph/models.py +++ b/caster-back/story_graph/models.py @@ -35,6 +35,31 @@ class Graph(models.Model): """ class StreamAssignmentPolicy(models.TextChoices): + """ + Each graph can handle different "connection" mechanisms when a listener + accesses a graph. + + The implementation of each policy is defined in :class:`~story_graph.engine.Engine`. + + .. list-table:: + :header-rows: 1 + + * - StreamAssignmentPolicy + - Comment + * - `ONE_GRAPH_ONE_STREAM` + - All users share the same stream. + When the first user visits a graph, a new stream will be set up. + Any following user visiting the same story graph stream will be + "redirected" to the same stream as long as there is still *any* + user listening to the graph. + All users still execute the story graph from the beginning. + * - `ONE_USER_ONE_STREAM` + - Upon connection, each user will obtain a new and exclusive stream + and the graph will be executed upon the stream. + * - `DEACTIVATE` + - Non functional, for administrative work. + """ + ONE_GRAPH_ONE_STREAM = "one_graph_one_stream", _( "Each graph has only one stream" ) diff --git a/caster-back/stream/__init__.py b/caster-back/stream/__init__.py index 82ffd1ca..0532a9a5 100644 --- a/caster-back/stream/__init__.py +++ b/caster-back/stream/__init__.py @@ -8,7 +8,7 @@ Graph ----- -.. figure:: ../../graphs/stream.png +.. figure:: ../graphs/stream.svg Model graph for the stream app. diff --git a/docs/Makefile b/docs/Makefile index c38f1a93..400ee961 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -17,9 +17,9 @@ help: build-graphs: export DJANGO_SETTINGS_MODULE=gencaster.settings.test build-graphs: echo "Start building model graph images" - cd ../caster-back && python manage.py graph_models --pydot -g -o ../docs/graphs/stream.png stream - cd ../caster-back && python manage.py graph_models --pydot -g -o ../docs/graphs/story_graph.png story_graph - cd ../caster-back && python manage.py graph_models --pydot -g -o ../docs/graphs/global.png stream story_graph + cd ../caster-back && python manage.py graph_models --pydot -g -o ../docs/graphs/stream.svg stream + cd ../caster-back && python manage.py graph_models --pydot -g -o ../docs/graphs/story_graph.svg story_graph + cd ../caster-back && python manage.py graph_models --pydot -g -o ../docs/graphs/global.svg stream story_graph echo "Finished building model graph images" # Catch-all target: route all unknown targets to Sphinx using the new diff --git a/docs/_static/custom.css b/docs/_static/custom.css index eeb2c93a..9203276a 100644 --- a/docs/_static/custom.css +++ b/docs/_static/custom.css @@ -48,8 +48,20 @@ html[data-theme='light'] a { color: var(--blue) !important } +html[data-theme='dark'] { + --blue: #fff !important; +} + /* {--background-color: #212a2e;--text-color: #F7F8F8;--link-color: #828fff;} */ .sig-name.descname .pre { background-color: var(--green); } + +.py.method { + margin-top: 25px; +} + +.py.class { + margin-top: 50px; +} diff --git a/docs/back/api/index.rst b/docs/back/api/index.rst deleted file mode 100644 index f033201c..00000000 --- a/docs/back/api/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -API -=== - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - ./story_graph.rst - ./stream.rst - ./gencaster.rst diff --git a/docs/back/api/gencaster.rst b/docs/back/gencaster.rst similarity index 100% rename from docs/back/api/gencaster.rst rename to docs/back/gencaster.rst diff --git a/docs/back/graphql.rst b/docs/back/graphql.rst deleted file mode 100644 index 9b4c9b87..00000000 --- a/docs/back/graphql.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _graphql: - -GraphQL -======= - -GraphQL is used as a communication protocol between *caster-back* and *caster-front* and *caster-editor*. - -Add queries ------------ - -.. todo:: - - Describe the steps necessary to add additional queries diff --git a/docs/back/index.rst b/docs/back/index.rst index d5308a52..c854b72c 100644 --- a/docs/back/index.rst +++ b/docs/back/index.rst @@ -14,16 +14,15 @@ The communication with *caster-sound*, the sound generating and streaming servic Global model graph ------------------ -.. figure:: ../graphs/global.png +.. figure:: ../graphs/global.svg Global model graph -API ---- - .. toctree:: + :hidden: osc_server.rst - graphql.rst - api/index.rst + story_graph.rst + stream.rst + gencaster.rst diff --git a/docs/back/api/story_graph.rst b/docs/back/story_graph.rst similarity index 100% rename from docs/back/api/story_graph.rst rename to docs/back/story_graph.rst diff --git a/docs/back/api/stream.rst b/docs/back/stream.rst similarity index 100% rename from docs/back/api/stream.rst rename to docs/back/stream.rst diff --git a/docs/conf.py b/docs/conf.py index 3d129e92..04b112c5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -88,3 +88,5 @@ autodoc_default_options = { "exclude-members": "DoesNotExist,MultipleObjectsReturned", } + +graphviz_output_format = "svg" diff --git a/docs/deployment.rst b/docs/deployment.rst index 3e256db7..7ceb8d59 100644 --- a/docs/deployment.rst +++ b/docs/deployment.rst @@ -1,3 +1,5 @@ +.. _deployment: + Deployment ========== @@ -39,7 +41,7 @@ while a dev deployment can look like this SENTRY_DSN_CASTER_FRONT="https://changeMe.io" -.. _services: +.. _deployment-services: Services ^^^^^^^^ diff --git a/docs/editor.rst b/docs/editor.rst index 46ee6f0d..d5c60a2d 100644 --- a/docs/editor.rst +++ b/docs/editor.rst @@ -9,10 +9,10 @@ Caster Editor .. seealso:: - This documents covers the editing of a *story graph*. - For the concepts of such a graph see :ref:`Story Graph`. + This documents covers the editing of a :term:`Story Graph` through the editor. + For an introduction to the concepts of Gencaster, such as the editing and capabilities of the story graph, also take a look ot the :ref:`tutorial`. -The editor is a website which allows to create and modify a :ref:`Story Graph`. +The editor is a website which allows to create and modify a :term:`Story Graph`. It is possible that many users at once can collaboratively edit this story graph, and also the modifications will be applied in real time to an already running stream, which allows for live coding setups. .. figure:: ./assets/editor.png @@ -49,6 +49,8 @@ There are multiple types of script cells for different contexts. e.g. PopUps on the :ref:`caster-front`. Anything that should be decided dynamically (e.g. day vs night) should be coded within Python. +.. _editor_markdown: + Markdown ^^^^^^^^ @@ -103,7 +105,7 @@ To use this ``name`` within a Markdown cell can be archived via .. code-block:: markdown - Hello ${var}`name`. I hope you are doing fine. + Hello {var}`name`. I hope you are doing fine. where the *${var}`name* will be replaced with the name provided through the popup, so for example *Hello Alice. I hope you are doing fine*. @@ -120,6 +122,8 @@ The *volume* slider controls the volume of the audio on the stream. The *edit* button allows to change the associated audio file by uploading a new file or search through existing files. +.. _editor_python: + Python ^^^^^^ diff --git a/docs/front.rst b/docs/front.rst deleted file mode 100644 index 60c2c3e0..00000000 --- a/docs/front.rst +++ /dev/null @@ -1,15 +0,0 @@ -.. _caster-front: - -Caster Front -============ - -A Javascript frontend which gets data from *caster-back* and allows to build a connection to *caster-sound* to obtain a stream. - -The GraphQL documentation can be accessed at :ref:`graphql`. - -Connection flow ---------------- - - -Templates ---------- diff --git a/docs/glossary.rst b/docs/glossary.rst new file mode 100644 index 00000000..3c84cac8 --- /dev/null +++ b/docs/glossary.rst @@ -0,0 +1,145 @@ +Glossary +======== + +.. glossary:: + + Backend + + See :term:`Services`. + + Django + + `Django `_ is used as the web server framework for Gencaster. + For example, it manages the database and wraps the :term:`Engine` into a :term:`GraphQL` connection. + + Docker + + Docker is a virtualization software which allows to specify the runtime of a service through code. + This helps to make the installation, deployment and management of Gencaster easier. + + Edge + Connection + + Connects an entry :term:`node door` with an exit node door. + + See :class:`story_graph.models.Edge`. + + Editor + + See :term:`Services`. + + Engine + + The story graph engine traverses the :term:`Story Graph` and manages any script cell executions and allocations. + + See :class:`story_graph.engine.Engine`. + + Frontend + + See :term:`Services`. + + Graph + Story Graph + + A graph is a key component of Gencaster and is used to define the score of a story within Gencaster. + A graph stores the content, metadata and code statements which will control and influence the stream of the listener. + Each Graph consists of multiple :term:`nodes ` which are connected through :term:`edges`. + + See :class:`story_graph.models.Graph`. + + GraphQL + + GraphQL has nothing to do with :term:`Story Graph`, but instead is a communication protocol used between :term:`Frontend` and :term:`Backend`. + + See :ref:`schema`. + + Janus + + The WebRTC server used to distribute/broadcast the sonic output of :term:`scsynth` via :term:`WebRTC`. + + Node + + A node is an entity within the :term:`Story Graph` and consists of any number of :term:`script cells