Skip to content

Commit

Permalink
Merge pull request #51 from zheylmun/feature/mermaid_v11
Browse files Browse the repository at this point in the history
Update to use latest mermaid version for access to new diagram types
  • Loading branch information
mersinvald authored Sep 25, 2024
2 parents e5a4d11 + 3313d19 commit 7d1b1cf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions demo/diagram_2.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packet-beta
0-15: "Option Length"
16-23: "Option Type"
24: "Discardable Flag"
25-31: "Reserved = 0x00"
18 changes: 11 additions & 7 deletions demo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// A function showcasing aquamarine defaults
///
/// With aquamarine it's possible to embed Mermaid diagrams into your Rust documentation using the code snippets
///
///
/// ```mermaid
/// graph LR
/// s([Source]) --> a[[aquamarine]]
Expand All @@ -28,8 +28,8 @@ pub fn example() {}
/// %%{init: {
/// 'theme': 'base',
/// 'themeVariables': {
/// 'primaryColor': '#ffcccc',
/// 'edgeLabelBackground':'#ccccff',
/// 'primaryColor': '#ffcccc',
/// 'edgeLabelBackground':'#ccccff',
/// 'tertiaryColor': '#fff0f0' }}}%%
/// graph TD
/// A(Diagram needs to be drawn) --> B{Does it have 'init' annotation?}
Expand All @@ -42,14 +42,18 @@ pub fn example_with_styling() {}

#[cfg_attr(doc, aquamarine::aquamarine)]
/// A diagram can be loaded from a file as well!
///
///
/// include_mmd!("diagram_0.mmd")
///
///
/// Reduce clutter in your doc comments, when a diagram is big enough.
///
///
/// You can include multiple diagrams in a single doc comment, using the macro-like syntax `include_mmd!("/path/to/diagram.mmd")`
///
///
/// include_mmd!(diagram_1.mmd)
///
/// Diagrams up to Mermaid version 11.1 are currently supported
///
/// include_mmd!(diagram_2.mmd)
///
/// **Note:** `indlude_mmd!` syntax is only supported inside doc comments
pub fn example_load_from_file() {}
2 changes: 1 addition & 1 deletion scripts/package_mermaid_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Usage: scripts/package_mermaid_release.sh doc/js https://cdn.jsdelivr.net/npm/mermaid@10/dist/ mermaid.esm.min.mjs

PKG_DIR="${1:-./doc/js}"
PKG_URL="${2:-https://cdn.jsdelivr.net/npm/mermaid@10.0.2/dist/}"
PKG_URL="${2:-https://cdn.jsdelivr.net/npm/mermaid@11.1.0/dist/}"
PKG_NAME="${3:-mermaid.esm.min.mjs}"

DOWNLOAD_DIR="${PKG_DIR}.dl"
Expand Down
2 changes: 1 addition & 1 deletion src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static MERMAID_JS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/doc/js/");
// base=document.getElementById("rustdoc-vars").attributes["data-root-path"]
const MERMAID_JS_LOCAL: &str = "static.files.mermaid/mermaid.esm.min.mjs";
const MERMAID_JS_LOCAL_DIR: &str = "static.files.mermaid";
const MERMAID_JS_CDN: &str = "https://unpkg.com/mermaid@10/dist/mermaid.esm.min.mjs";
const MERMAID_JS_CDN: &str = "https://unpkg.com/mermaid@11.1/dist/mermaid.esm.min.mjs";

const UNEXPECTED_ATTR_ERROR: &str =
"unexpected attribute inside a diagram definition: only #[doc] is allowed";
Expand Down

0 comments on commit 7d1b1cf

Please sign in to comment.