-
Notifications
You must be signed in to change notification settings - Fork 3.8k
🧜♀️ Mermaid Graphs #1953
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
🧜♀️ Mermaid Graphs #1953
Conversation
Firstly, thanks for this really excellent PR. The mermaid graphs are much clearer than the GraphViz SVGs.
Each module should have a dependency graph unless there's a special reason not to, for this reason
Sounds good to me. This change should be documented somewhere. The Modularization learning journey is the most obvious place to do this. Changes:
|
I've added a For the CI validation step, I've just copy/pasted the dependency graph block and adapted it to the graphs, but I feel like this should probably need a refactor. For instance, having an early "validation" job that takes care of these kind of update, and only after that, we execute the build/test/androidTest jobs. But it is probably out of the scope of this PR. I still need to test this (for example if new modules are added or deleted)
Any suggestion? Should we try to map the current svg as close as possible?
Do you think of documenting this in the same document?
I'm not sure if it makes sense to document both of them.
I don't think workflows are currently documented anywhere. Any suggestion? |
Yes, I would do that. The goal of that chart is to demonstrate the different types (
Yes, unless you can think of a more suitable place? If it was easy to add a legend to each module graph then that could be a better option.
Let's add a section "Module graphs" at the end and mention:
As above. Happy to do any/all of this if you want to delegate to me. |
build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/Graph.kt
Show resolved
Hide resolved
as an alternative: dorongold/gradle-task-tree#41 (comment) |
Hi @OleksandrKucherenko thanks for your input but this has nothing to do with task graphs. |
Yep, I notice that too late. Check another comment for more related to the dependencies graph. |
ColorsDo you want to reuse the colors of the SVG or something like that (or something different)?
Types of modulesHere is my attempt at re-creating the SVG, without trying to go too far with invisble block to try mimic-ing the original layout. As you can see, there are not differences between regular libraries and "features". Do we want to display them differently? In this case, I can adapt the plugin code to look for graph TB
subgraph :core
direction TB
:core:data[data]:::android-library
:core:database[database]:::android-library
:core:model[model]:::jvm
:core:network[network]:::android-library
:core:ui[ui]:::android-library
end
subgraph :feature
direction TB
:feature:topic[topic]:::android-library
:feature:foryou[foryou]:::android-library
:feature:interests[interests]:::android-library
:feature:foo[...]:::android-library
end
:app[app]:::android-application
:app -.-> :feature:foryou
:app -.-> :feature:interests
:app -.-> :feature:topic
:core:data ---> :core:database
:core:data ---> :core:network
:core:database ---> :core:model
:core:network ---> :core:model
:core:ui ---> :core:model
:feature:topic -.-> :core:data
:feature:topic -.-> :core:ui
classDef android-application fill:#536DFE,stroke:#fff,stroke-width:2px,color:#fff;
classDef android-library fill:#3BD482,stroke:#fff,stroke-width:2px,color:#fff;
classDef jvm fill:#7F52FF,stroke:#fff,stroke-width:2px,color:#fff;
Legendssomething very simplegraph TB
application:::android-application -. implementation .-> feature:::android-library
library:::android-library -- api --> jvm:::jvm
classDef android-application fill:#536DFE,stroke:#fff,stroke-width:2px,color:#fff;
classDef android-library fill:#3BD482,stroke:#fff,stroke-width:2px,color:#fff;
classDef jvm fill:#7F52FF,stroke:#fff,stroke-width:2px,color:#fff;
or a more complex wiht real names?graph TB
:app[:app]:::android-application
:feature:topic[:feature:topic]:::android-library
:app -. implementation .-> :feature:topic
:core:database[:core:database]:::android-library
:core:model[:core:model]:::jvm
:core:database -- api --> :core:model
classDef android-application fill:#536DFE,stroke:#fff,stroke-width:2px,color:#fff;
classDef android-library fill:#3BD482,stroke:#fff,stroke-width:2px,color:#fff;
classDef jvm fill:#7F52FF,stroke:#fff,stroke-width:2px,color:#fff;
Docs## Module graphs
Each module has its own `README.md` file containing a module graph (e.g. [`:app` module graph](../app/README.md#module-dependency-graph)).
When modules dependencies change, module graphs are automatically updated by the [Build.yaml](../.github/workflows/Build.yaml) workflow.
You can also manually update the graphs by running the `graphUpdate` task. |
Looks good. I would remove the Yes to displaying the feature modules differently, just choose any unallocated color from the above theme.
Simple looks good
Looks great 👍 |
| Type | Plugin ID | Color | |-------------|------------------------------------|------------------------| | Application | `nowinandroid.android.application` | `#CAFFBF` PastelGreen | | Feature | `nowinandroid.android.feature` | `#FFD6A5` PastelOrange | | Library | `nowinandroid.android.library` | `#9BF6FF` PastelBlue | | Test | `nowinandroid.android.test` | `#A0C4FF` PastelMauve | | JVM | `nowinandroid.jvm.library` | `#BDB2FF` PastelPurple | | Unknown | `?` | `#FFADAD` PastelRed |
I've updated the color mapping with this:
|
Once again, thanks for all your hard work here. I filed a follow up feature request #1962 so this PR could be merged without any further delay. |
This PR replaces the current dependency graphs generated by jraska/modules-graph-assert and then converted to SVG when executing the generateModuleGraphs.sh script (relying on
dot
&svgo
) with inlined Mermaid graphs that are automatically rendered on GitHub.See #1554 for more details.
There are still some questions left to answer before merging:
graphDump
andgraphUpdate
are currently being registered in a few different places, like "base" plugins. We could instead create a new plugin to automatically register them, or register them once from the root project withallprojects
or keep it like this for now.README.md
files like we do for screenshots.