-
Notifications
You must be signed in to change notification settings - Fork 18
Fix bin/gen_diagrams that is referenced in docs
#1291
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a5cff27
add missing command
jeff-hykin f254a3c
Apply suggestion from @greptile-apps[bot]
jeff-hykin aaa4e98
fix
jeff-hykin 028429a
Merge branch 'jeff/fix/gen-diagrams' of github.com:dimensionalOS/dimo…
jeff-hykin 1056faa
Update bin/gen-diagrams
jeff-hykin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| cd "$REPO_ROOT" | ||
|
|
||
| # if md-babel-py doesnt exist | ||
| if [ -z "$(command -v "md-babel-py")" ]; then | ||
| # if nix doesnt exist | ||
| if [ -z "$(command -v "nix")" ]; then | ||
| echo "Error: md-babel-py required for running gen-diagrams." >&2 | ||
| echo " Either install nix or install md-babel-py" >&2 | ||
| echo " https://github.com/leshy/md-babel-py" >&2 | ||
| exit 1 | ||
| # use nix if local command doesn't exist | ||
| else | ||
| md-babel-py() { | ||
| nix run github:leshy/md-babel-py -- "$@" | ||
| } | ||
| fi | ||
| fi | ||
|
|
||
| diagram_langs="asymptote,pikchr,openscad,diagon" | ||
| if [[ "$#" -gt 0 ]]; then | ||
| for arg in "$@"; do | ||
| md-babel-py run "$arg" --lang "$diagram_langs" | ||
| done | ||
| else | ||
| while IFS= read -r file; do | ||
| md-babel-py run "$file" --lang "$diagram_langs" | ||
| done < <(find ./docs -type f -name '*.md' | sort) | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leshy this is your stuff is this fine
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this does is executes
md-babel-py run- this is just another adapter layer to maintain and should be a personal shell alias not a /bin/ script imo.if others need this, that's ok and can add it - but expectation is for scripts in /bin/ to always work and be up to date
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~30 lines is not an alias; even ignoring the installation help/check, at the bottom there's a for loop for iterating over all the file paths -- a for loop doesn't fit in an alias. I have lots of my own aliases for things that are just-for-me. This was designed specifically to help others.
Idk why but md-babel-py seems to only be able to handle one file path at a time, using shell globbing doesn't work. If you add support for that it would make this wrapper less necessary.
Yes? This function should always work. If contributors are not able to generate diagrams for docs in one line thats a problem IMO. Why would we make each person on the team copy this wrapper and define it in their own shell?
If we add a new diagram lang we can just change this function instead of telling everyone else to change their alias's.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anything IMO it would be nice to add a
--watchflag to this script so that real-time editing of diagrams can be rendered locally instead of needing to run the command every time.Also I made a PR on md-babel-py to make it work with Nix on MacOS whenever you get the chance to merge it:
leshy/md-babel-py#1
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I merged your md-babel PR, and published to pypy (v1.1.2) tnx for mac support!
I actually didn't write a single diagram by hand yet (have you?) agents have been drawing those for me, in docs instructions they know how to regenerate, this is why I didn't work on ergonomics of this.
but all above is good and reasonable imo, I'd prefer to add these things to md-babel-py directly, both
--watchand--recursive, instead of adding an adapter layer like this. md-babel-py is a mostly quickly vibed project for me to write the docs, so I'd just vibe those commands as well.As for re-generating diagrams, I'd add an option (temporarily) directly to
md-babel-py---diagramsbut actually much better, I wouldn't differentiate code blocks vs diagram blocks and I'd add some caching mechanism (hash in code block args after language) for unchanged code blocks to not be re-evaluated.I still think above adds a random layer that should be in md-babel-py but won't block since not very important, I let you decide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, would definitely prefer that to be builtin to md-babel.
For diagrams specifically I think for speed it makes sense to just want to generate diagrams (it can take quite a while to run the full code in blueprints.md), and also diagrams can't (or shouldn't) have effects outside of making an image/svg. Maybe a cache plus block-change-detection in md-babel would make it where that doesnt matter.
Once md-babel has --watch let's revisit and just have a "we use md-babel for our docs/diagrams" but for now I think bin/gen-diagrams is a useful stop-gap.
1 month from now I think it would be good to re-asses all the stuff in bin (I'm pretty sure robot debugger doesnt work, and bin/pytest-fast is an alias-level wrapper)