Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 8 additions & 16 deletions .github/workflows/generateUml.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Generate UML Diagrams

on:
push:
pull_request:
branches:
- master
workflow_dispatch:
Expand All @@ -28,29 +28,21 @@ jobs:
run: npm install -g tplant@3.1.0

- name: Generate PlantUML class diagram from source
run: tplant -i src/lib/famix/**/*.ts -o doc-uml/famix-typescript-model.puml

- name: Generate SVG Diagram from PlantUML
uses: Timmy/plantuml-action@v1
with:
args: -v -config "doc-metamodel/skins.include.cfg" -tsvg doc-uml/famix-typescript-model.puml
run: npm run uml

- name: Check for changes in UML diagrams
id: check_changes
run: |
if git status --porcelain | grep 'doc-uml/famix-typescript-model.puml\|doc-uml/famix-typescript-model.svg'; then
if git status --porcelain | grep 'doc-uml/famix-typescript-model.puml'; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi

- name: Push docs to current branch
- name: Fail if UML diagrams are outdated
if: steps.check_changes.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add -v doc-uml
git commit -v -m "Update docs for branch ${{ github.ref_name }}"
git push origin HEAD:refs/heads/${{ github.ref_name }} # Push to the branch that triggered the workflow
echo "Generated UML documentation is out of date."
echo "Run 'npm run uml', commit the updated files in doc-uml/, and update this pull request."
git diff -- doc-uml
exit 1
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ To import sunit test inside moose:

## TypeScript Metamodel API documentation (visualization)

The following was generated by CI using [tplant](https://github.com/bafolts/tplant), in a similar fashion described [here](https://modularmoose.org/posts/2021-07-19-automatic-metamodel-documentation-generation).
The UML files in `doc-uml/` are versioned with the source. CI now checks that they are up to date and fails the pull request if they are not.

![FamixTypeScript API Metamodel](doc-uml/famix-typescript-model.svg)
When a change affects the TypeScript metamodel in `src/lib/famix/`, update the UML before pushing:

```sh
npm install
npm run uml
git add doc-uml
git commit -m "Update UML documentation"
```

The following diagram is generated using [tplant](https://github.com/bafolts/tplant), in a similar fashion described [here](https://modularmoose.org/posts/2021-07-19-automatic-metamodel-documentation-generation).

![FamixTypeScript API Metamodel](https://www.plantuml.com/plantuml/proxy?cache=no&fmt=svg&src=https://raw.githubusercontent.com/fuhrmanator/FamixTypeScriptImporter/refs/heads/master/doc-uml/famix-typescript-model.puml)
199 changes: 155 additions & 44 deletions doc-uml/famix-typescript-model.puml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc-uml/famix-typescript-model.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 64 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install",
"doc": "typedoc && touch docs/.gitkeep",
"coverage": "jest --colors --silent --coverage --coverageDirectory=coverage",
"uml": "./src/generate_uml.sh"
"uml": "tplant -i \"src/lib/famix/**/*.ts\" -o doc-uml/famix-typescript-model.puml && node -e \"const fs = require('fs'); const f = 'doc-uml/famix-typescript-model.puml'; fs.writeFileSync(f, fs.readFileSync(f, 'utf8').replace('@startuml', '@startuml metamodel'));\""
},
"bin": {
"ts2famix": "dist/ts2famix-cli-wrapper.js"
Expand Down
20 changes: 0 additions & 20 deletions src/generate_uml.sh

This file was deleted.

Loading