Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ochko/markdoc
Markdown with flowchart and sequence diagram
https://github.com/ochko/markdoc
documentation markdown pseudocode svg
Last synced: 20 days ago
JSON representation
Markdown with flowchart and sequence diagram
- Host: GitHub
- URL: https://github.com/ochko/markdoc
- Owner: ochko
- Created: 2015-04-11T15:53:19.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-06-15T04:39:33.000Z (over 2 years ago)
- Last Synced: 2025-01-03T00:09:29.991Z (28 days ago)
- Topics: documentation, markdown, pseudocode, svg
- Language: Ruby
- Homepage:
- Size: 60.5 KB
- Stars: 59
- Watchers: 2
- Forks: 18
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Markdoc
A markdown to html converter with sequence diagram and flowchart support. Generating documents including diagrams has advantages:
- Docs can be checked into version control like source code, and can compare changes effectively as it is all text
- Making and updating diagrams using drawing software is slowIt converts markdown codeblocks for diagrams using [Graphviz](http://www.graphviz.org). Pseudocode to Graphviz is inspired by this [gist](https://gist.github.com/antimatter15/1841460). Pseudocode is converted to dot file and then Graphviz's `dot` program converts it to vector image.
## System requirements
- Ruby 2.7.6 and up
- Graphviz (tested with dot version 3.0.0)#### OS X
`$ brew install graphviz`
#### Linux (debian, ubuntu)
`$ apt-get install graphviz`
#### Linux (fedora, rhel or centos)
`$ yum install graphviz`
## Installing
`$ gem install markdoc`
For bundler add `gem markdoc` to your Gemfile.
## Usage
`$ markdoc document.md > document.html`
Generated html includes inline svg diagrams, eliminating need for attached image files. It provides 3 executables:
- `markdoc` converts markdown document to html
- `pseudo2svg` converts pseudocode to svg image (see below for pseudocode format)
- `sequence2svg` converts sequence diagram spec to svg image(see below for sequence diagram spec format)### Pseudocode blocks
Currently it supports only `if/else` branch logic, but you can achieve a lot with it.
```
if ConditionN
Action-A
Action-B
else
Action-C
end
```Include codeblock with `pseudo` language in your markdown.
```pseudo
visit registration page
enter email address
if new user
fill in registration form
submit
if validation error
fix registration form
review the fix
submit
else
submit
end
else
enter password
if password wrong
ask password again
else
good to go
end
confirm account info
end
confirm registration info
```Or you could compile individual pseudocode to vector image. Below is generated by:
`$ pseudo2svg examples/example.pseudo > examples/flowchart.svg`
![flowchart](http://ochko.github.io/markdoc/examples/flowchart.svg "Flowchart")
### Sequence diagram
Include codeblock with `sequence` language in your markdown. Sequence diagram starts with actor declaration(becomes symbol of man), then object declaration(becomes big rectangles with vertical lifeline), then follows messages. Message format is:
- `A -> B : Label` - Arrow from A to B with Label over it. Arrows work either way, so it is equivalent to `B <- A : Label`
- `A <~ B : Label` - Dashed arrow representing return message. Also works for other direction. so it is same as `B ~> A : Label`
- `C : Label` - Message to C itself. Actually it is same as `C -> C : Label`
```sequence
Student = Actor
P = Partner Site
App = Web App
Api = Reg APIStudent -> P : Choose course(S)
P -> Api : Issue key for(S)
P <~ Api : Registration key(K)
P -> App : Register with key(K)
Student <~ App : Registration form
Student -> App : Fill the form(F)
App : Save the form(F)
App -> Api : Register(K, F) # New API
Api : Create course
App <~ Api : Course details(C)
App : Save(C)
Student <~ App : Show course summary
Student -> Api : Click study button
Student <~ Api : Show mypage
```Or you could compile individual sequence diagram to vector image. Below is generated by:
`$ sequence2svg examples/example.sequence > examples/sequence.svg`
![sequence](http://ochko.github.io/markdoc/examples/sequence.svg "Sequence")
### Others
When printing docs you might want to break pages at specific line. You can use this markup for that:
```html
```See [examples/doc.md](https://raw.githubusercontent.com/ochko/markdoc/master/examples/doc.md) for complete example.
## Contributing
Fork the repo, and send a pull request. I promise I will merge almost all PR's as soon as you don't break existing behaviour. ;) More than welcome if you implement other diagram types. Please add a bit of test for your implementation if you add a feature.
## Boring legal stuff
The MIT License (MIT)
Copyright (c) Lkhagva Ochirkhuyag, 2022
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.