1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AsciiDocでUMLファイル (PlantUML , Mermaid)を参照する方法

Posted at

はじめに

 AsciiDocで、PlantUMLとMermaidのUMLファイル参照する方法を紹介する。個別にUMLファイルを管理することで、ファイルの重複管理を避けることができる。また、単独のUMLファイルとUMLを参照したAsciiDocの両方でUML表示ができるような構成とする。

動作確認完了

方法

ポイント

  • 参照されるUMLファイルは、単体でGitLabやVSCodeでUML表示を可能とするためMarkdownにする
  • 上記UMLファイルを参照するAsciiDocでは、マークダウン書式を除外するために行数を指定してincludeする

詳細は以下を参照。

PlantUML

例: PlantUMLファイルの相対パス(./resources/plantuml_test_class_diagram.md)の場合

[plantuml, align="center"]
----
include::./resources/plantuml_test_class_diagram.md[lines=2..3]
----

 [lines=a..b]で、a行目からb行目までを読み込む。マークダウンのヘッダー(```plantuml)とフッター(```)を除くUML本体の行数を指定する。

注意点

  • -1で最終行を指定できるが、最終行から2行目などは指定できないため(-2としても最終行となる)、inlucdeするUMLファイルを確認して行数を直接指定する必要がある

Mermaid

例: Mermaid UMLファイルの相対パス(./resources/mermaid_test_class_diagram.md)の場合

[mermaid, align="center"]
----
include::./resources/mermaid_test_class_diagram.md[lines=2..3]
----

行数の指定方法などは、PlantUMLの場合と同様。

まとめ

 AsciiDocでPlantUMLやMermaidのUMLファイルを参照(include)する方法を紹介した。単独のUMLファイルでもGitLabやVSCodeでUML表示が働くようにMarkdownファイルとし、参照するAsciiDocでincludeする行数を指定することで、AsciiDocでの表示も可能とすることができた。

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?