Skip to content
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 template for the confluence mermaid-cloud plugin. #285

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,32 @@ And attach any image with the following
The width will be the commented html after the image (in this case 300px).


### Usage with the mermaid-cloud plugin

> Note: The mermaid-cloud plugin needs to be added to your Confluence instance

This plugin uses attachments to provide and place the graph in your confluence page, so don't forget to add the attachment.

```mardown
zopanix marked this conversation as resolved.
Show resolved Hide resolved
<!-- Attachment: graph.mermaid -->
<!-- Macro: :mermaid:(.+):(.*):(.*)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we start this type of workarounds with custom macros, I think it would be cleaner to have a --mermaid-provider CLI flag and render fenced codeblocks with mermaid language accordingly.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe even specify MERMAID_PROVIDER via environment variables so it's easier to adjust these settings for CI/CD users

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should replace docopt-go with https://github.com/spf13/viper or similar?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I do understand these concerns. The mermaid-cloud plugin only works with attachments. We could add a dynamic attachment when we choose the mermaid provider but tbh, that might be a bit too much for me.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honnest, I don't think I have the time or capacity to develop the provider selector logic and add it in my PR. But I will be happy to re-submit a PR once it's in place with my provider. Whether you allow this to currently exists or not doesn't affect me since we'll probably maintain a fork while the above gets implemented.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I want to work towards a PR that includes https://github.com/dreampuf/mermaid.go / #167 and will add support for multiple implementations there.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a plan, am going to close this PR and open a new one once everything is ready.

Template: ac:mermaidcloud
Filename: ${1}
Revision: ${2}
Layout: ${3}
-->

```

> Note: This is a complete example, but Revision and Layout can be ommited from the Template as they are optional.

And now you only need to add the following to add the mermaid diagram:

```
:mermaid:graph.mermaid:1:default:
```


## Installation

### Homebrew
Expand Down
9 changes: 9 additions & 0 deletions pkg/mark/stdlib/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ func templates(api *confluence.API) (*template.Template, error) {
`ac:anchor`: text(
`<ac:structured-macro ac:name="anchor">{{printf "\n"}}`,
`<ac:parameter ac:name="">{{ .Anchor }}</ac:parameter>{{printf "\n"}}`,
`</ac:structured-macro>{{printf "\n"}}`,
),

/* https://stratus-addons.atlassian.net/wiki/spaces/MDFC/overview?homepageId=1650262147 */

`ac:mermaidcloud`: text(
`<ac:structured-macro ac:name="mermaid-cloud" ac:schema-version="1" data-layout="{{ if .Layout }}{{ .Layout }}{{ else }}default{{ end }}">{{printf "\n"}}`,
`{{ if .Filename }}<ac:parameter ac:name="filename">{{ .Filename }}</ac:parameter>{{printf "\n"}}{{end}}`,
`{{ if .Revision }}<ac:parameter ac:name="revision">{{ .Revision }}</ac:parameter>{{printf "\n"}}{{end}}`,
`</ac:structured-macro>{{printf "\n"}}`,
),

Expand Down