Skip to content

Commit

Permalink
⬆️ 📚 Update diagrams to mermaid
Browse files Browse the repository at this point in the history
  • Loading branch information
elbeno committed Dec 7, 2023
1 parent 2853f82 commit ce8c147
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 142 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/asciidoctor-ghpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Mermaid
run: |
sudo npm install -g @mermaid-js/[email protected]
node /usr/local/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer/install.js
- name: Install asciidoctor
run: |
sudo apt update
Expand All @@ -45,7 +53,6 @@ jobs:
if [ -e docs/static ]; then cp -rf docs/static ./generated-html; fi
touch ./generated-html/.nojekyll
ls -la ./generated-html
cat ./generated-html/index.html
- name: Setup github pages
if: needs.configure.outputs.enable_publish == 'true'
uses: actions/configure-pages@v4
Expand Down
204 changes: 63 additions & 141 deletions docs/flows.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,18 @@ dependencies.
If we only use the `morning` component in our project, the `MorningRoutine` flow
graph would look like the following:

[ditaa, format="svg", scale=1.5]
----
/------------------\
| MorningRoutine |
| cGRE |
| |
| /---------\ |
| | WAKE_UP | |
| \---------/ |
| | |
| v |
| /--------\ |
| | SHOWER | |
| \--------/ |
| | |
| v |
| /-------------\ |
| | GET_DRESSED | |
| \-------------/ |
| | |
| v |
| /-------------\ |
| | MAKE_COFFEE | |
| \-------------/ |
| | |
| v |
| /--------------\ |
| | DRINK_COFFEE | |
| \--------------/ |
\------------------/
[mermaid, format="svg"]
----
flowchart TD
a(WAKE_UP)
b(selfcare::SHOWER)
c(selfcare::GET_DRESSED)
d(food::MAKE_COFFEE)
e(food::DRINK_COFFEE)
a --> b
b --> c
c --> d
d --> e
----

The power of `flow` services comes when more than one component adds actions to
Expand Down Expand Up @@ -121,56 +103,27 @@ struct childcare {

The new steps are inserted into the existing `flow`​'s dependency graph:

[ditaa, format="svg", scale=1.5]
----
/--------------------------------\
| MorningRoutine |
| cGRE |
| |
| /---------\ |
| | WAKE_UP | |
| \---------/ |
| | |
| v |
| /--------\ |
| | SHOWER | |
| \--------/ |
| | |
| v |
| /-------------\ |
| | GET_DRESSED | |
| \-------------/ |
| | |
| v |
| /-------------\ |
| | MAKE_COFFEE | |
| \-------------/ |
| | | |
| | v |
| | /---------------------\ |
| | | PACK_SCHOOL_LUNCHES | |
| | \---------------------/ |
| | | |
| v v |
| /--------------\ |
| | DRINK_COFFEE | |
| \--------------/ |
| | |
| v |
| /----------------\ |
| | MAKE_BREAKFAST | |
| \----------------/ |
| | |
| v |
| /---------------\ |
| | EAT_BREAKFAST | |
| \---------------/ |
| | |
| v |
| /---------------------\ |
| | SEND_KIDS_TO_SCHOOL | |
| \---------------------/ |
\--------------------------------/
[mermaid, format="svg"]
----
flowchart TD
a(WAKE_UP)
b(selfcare::SHOWER)
c(selfcare::GET_DRESSED)
d(food::MAKE_COFFEE)
e(food::DRINK_COFFEE)
a --> b
b --> c
c --> d
d --> e
f(food::MAKE_BREAKFAST)
g(food::EAT_BREAKFAST)
h(childcare::PACK_SCHOOL_LUNCHES)
i(childcare::SEND_KIDS_TO_SCHOOL)
d --> h
h --> e
e --> f
f --> g
g --> i
----

Multiple independent components can add actions to the same `flow`. This is the
Expand All @@ -179,7 +132,7 @@ components to create new functionality.

[source,cpp]
----
namespace exercise {
struct exercise {
constexpr static auto RIDE_STATIONARY_BIKE = flow::action<"RIDE_STATIONARY_BIKE">([] {
// ...
});
Expand All @@ -189,69 +142,38 @@ namespace exercise {
morning::WAKE_UP >>
RIDE_STATIONARY_BIKE >>
selfcare::SHOWER));
}
};
----

The `MorningRoutine` `flow` now contains the functionality of three components,
all without the `MorningRoutine` source code having known about the new
functionality. We can mix and match new components without modifying the
original source code.

[ditaa, format="svg", scale=1.5]
----
/---------------------------------\
| MorningRoutine |
| cGRE |
| |
| /------------\ |
| | WAKE_UP | |
| \------------/ |
| | | |
| | v |
| | /----------------------\ |
| | | RIDE_STATIONARY_BIKE | |
| | \----------------------/ |
| | | |
| v v |
| /------------\ |
| | SHOWER | |
| \------------/ |
| | |
| v |
| /-------------\ |
| | GET_DRESSED | |
| \-------------/ |
| | |
| v |
| /-------------\ |
| | MAKE_COFFEE | |
| \-------------/ |
| | | |
| | v |
| | /---------------------\ |
| | | PACK_SCHOOL_LUNCHES | |
| | \---------------------/ |
| | | |
| v v |
| /--------------\ |
| | DRINK_COFFEE | |
| \--------------/ |
| | |
| v |
| /----------------\ |
| | MAKE_BREAKFAST | |
| \----------------/ |
| | |
| v |
| /---------------\ |
| | EAT_BREAKFAST | |
| \---------------/ |
| | |
| v |
| /---------------------\ |
| | SEND_KIDS_TO_SCHOOL | |
| \---------------------/ |
\---------------------------------/
[mermaid, format="svg"]
----
flowchart TD
a(WAKE_UP)
b(selfcare::SHOWER)
c(selfcare::GET_DRESSED)
d(food::MAKE_COFFEE)
e(food::DRINK_COFFEE)
a --> b
b --> c
c --> d
d --> e
f(food::MAKE_BREAKFAST)
g(food::EAT_BREAKFAST)
h(childcare::PACK_SCHOOL_LUNCHES)
i(childcare::SEND_KIDS_TO_SCHOOL)
d --> h
h --> e
e --> f
f --> g
g --> i
j(exercise::RIDE_STATIONARY_BIKE)
a --> j
j --> b
----

The `cib` library will take care of initializing and building all services,
Expand All @@ -263,22 +185,22 @@ runtime.
----
MorningRoutine
1. WAKE_UP
2. RIDE_STATIONARY_BIKE
2. exercise::RIDE_STATIONARY_BIKE
3. selfcare::SHOWER
4. selfcare::GET_DRESSED
5. food::MAKE_COFFEE
6. PACK_SCHOOL_LUNCHES
6. childcare::PACK_SCHOOL_LUNCHES
7. food::DRINK_COFFEE
8. food::MAKE_BREAKFAST
9. food::EAT_BREAKFAST
10. SEND_KIDS_TO_SCHOOL
10. childcare::SEND_KIDS_TO_SCHOOL
----

All of these components are composed in a project component and brought to life
with an instance of `cib::top`. We need to make sure our `flow`​s get executed at
the appropriate times, so our example has a `day_cycle` component that defines
the various extension points and ensures they get executed over and over in
`cib::top`'s `MainLoop`.
`cib::top`'s `MainLoop`.

[source,cpp]
----
Expand Down

0 comments on commit ce8c147

Please sign in to comment.