-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: add support for docs directive #4
base: master
Are you sure you want to change the base?
Conversation
pystructurizr/dsl.py
Outdated
@@ -74,7 +74,7 @@ def dump_relationships(self, dumper: Dumper) -> None: | |||
|
|||
|
|||
class Person(Element): | |||
def dump(self, dumper: Dumper) -> None: | |||
def dump(self, dumper: Dumper, with_docs: bool = True) -> None: |
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 dislike this, but because Workspace
stores Person
s and SoftwareSystem
s as List[Element]
, they both need to implement the same interface 😬
Thanks for the PR. I'm not a huge fan of the !docs and !adrs directives, I find it strange that a tool that is essentially for diagrams-as-code is also used to generate a documentation site that then includes said diagrams. Therefore, I'm not inclined to integrate this PR, especially as it complicates the code and makes the interface of some classes a bit strange, as you also indicate in your comments. Since docs are just markdown files, why not use any other static site generator, and include the diagrams you generate with pystructurizr with regular |
I don't disagree with that notion, it does seem like an interesting choice that the DSL includes these directives, as opposed to embedding the diagrams within existing documentation.
Unfortunately this is where I disagree, as long as the intent of this project is to provide Python bindings for the Structurizr DSL. If you only intend for this project to support the subset of the DSL that you use in your projects, then I've misunderstood and I'll take down my PR and use my fork. However, I think if this project is intending to be the Python equivalent for Structurizr DSL, implementing explicitly included DSL features should be supported, no matter our personal thoughts on those DSL design decisions. I don't love what the changeset does for classes, but I think that's unavoidable based on the composition model of Structurizr's DSL.
This is a reasonable implementation as well, but I'd prefer to stick within the existing Structurizr ecosystem by supporting official DSL features. It would also be good if existing ecosystem tools worked natively with I don't intend to hijack your project and I appreciate the work you've put in to support the subset of DSL that the project currently supports. This is a feature of the DSL that people (including myself) use, so I think it's valuable to implement. I hope to be able to contribute Would love to continue to build on the great foundation you have here 🙂 |
I think I'm somewhere in the middle:
If you look at the first statement in the README of this project, it states: "PyStructurizr provides a Python DSL inspired by Structurizr, and is intended for generating C4 diagrams." I think that captures my intent with this project well. I'm using Structurizr DSL and Kroki under the hood, because that seemed like a fast track to generating C4 diagrams. That doesn't mean PyStructurizr should be able to output every possible statement that is valid in the DSL. For instance, the
Adding
I would like that as well! Can we find a less obtrusive way of adding the |
Sorry for delay, had a short vacation 🙂
This feels like a much better implementation. I'll work on implementing this. I also agree that there's some "interesting" choices made in the DSL, including the |
I suspect that most users of Structurizr are embedding diagrams into existing documentation ... whether that's Markdown/AsciiDoc (via Hugo, Jekyll, etc) or Confluence/SharePoint/etc. The Structurizr cloud service/on-premises installation/Lite provides a simple documentation generator for smaller teams who may not have anything already, which is why the DSL supports
@crossk3 ... the existing Structurizr for Python library might be worth taking a look at. It was recently archived (because the author uses the Structurizr DSL instead), but might provide some inspiration for adding docs support (by which I mean the class structure ... it also doesn't seem to support docs). |
7a341c7
to
07e7ffe
Compare
@nielsvanspauwen Sorry for the extreme delay, I see you beat me to the punch on I've updated the implementation of directives to be less intrusive on the object models, and now the decision to include the directives is on Hopefully the new implementation is less objectionable, lol. Although this PR relies on the "fix tests" PR, so those changes are on this branch as well. |
488d2bd
to
3c613bb
Compare
3c613bb
to
87d80db
Compare
Adds support for the
!docs
directive. This directive is valid for Workspaces, Software Systems, and Containers. However,kroki.io
doesn't support!docs
(obviously), so we need to be able to toggle whether we include these additional directives in thedump
.Unfortunately, because Models contain both
Person
s andSoftwareSystem
s, to fit the current implementation,Person.dump
needs to acceptwith_docs
argument and do nothing with it, whileSoftwareSystem.dump
acts on the argument. I don't like this, and am open to suggestions on a better implementation. I can see this getting worse whenGroup
is supported, as it would also be anElement
that needs to acceptwith_docs
. There's also the additional complication of future!adrs
support, etc.This enables users to include
docs=docs
kwarg in any of the supported objects, runpystructurizr dump > workspace.dsl
and then serve thedsl
through a rendering engine of their choice that supports!docs
. For example, I'm choosing to have the following file structure:workspace.dsl
includes directives such as!doc docs
which when served viadocker run -it --rm -v $(pwd):/var/model -p 8080:8080 ghcr.io/avisi-cloud/structurizr-site-generatr serve -w workspace.dsl
imports thedocs
directory as appropriate.