您可以点击此处在此页面上做出贡献  (Menu)


You can vote to improve syntax about packages/namespaces !

 

 

命令行

您也可以使用下面的命令行运行PlantUML:

java -jar plantuml.jar file1 file2 file3

这将在 file1, file2file3 中寻找 @startXXX。 对于每个图表, 都将创建一个 .png 文件。

对于处理整个文件夹, 您可以使用:

java -jar plantuml.jar "c:/directory1" "c:/directory2"

此命令将寻找 @startXXX@endXXX 位于 c:/directory1c:/directory2 目录中的 .c, .h, .cpp, .txt, .pu, .tex, .html, .htm.java 文件。

 

 

通配符

您也可以使用通过符 :

所以处理所有以 dummy 开始的目录的任意 .cpp 文件:

java -jar plantuml.jar "dummy*/*.cpp"

和处理以 dummy 开始的目录及其子目录中的任意 .cpp 文件 :

java -jar plantuml.jar "dummy*/**.cpp"

 

 

排除文件

您可以使用 -x 选项来排除处理队列中的某些文件:

java -jar plantuml.jar -x "**/common/**" -x "**/test/Test*" "dummy*/**/*.cpp" 

 

 

输出目录

您可以使用 -o 开关来指定一个输出所有图片的目录:

java -jar plantuml.jar -o "c:/outputPng" "c:/directory2"

如果您递归进入几个目录,如果为此输出目录提供绝对路径或相对路径,则会略有不同。

 

 

配置文件

您还可以在每个图表之前提供将包含的配置文件:

java -jar plantuml.jar -config "./config.cfg" dir1

 

 

Metadata

After all preprocessing (includes etc), PlantUML saves the diagram's source code in the generated PNG Metadata in the form of encoded text.

Sounds like magic! No, merely clever engineering :-)

Example:

  java -jar plantuml.jar -metadata diagram.png > diagram.puml

Unfortunately this option works only with local files. It doesn't work with -pipe so you cannot fetch a URL with eg curl and feed the PNG to PlantUML.

However, the Plantuml server has a similar feature, where it can get a PNG from a URL and extract its metadata.

 

 

退出代码

当图表中存在一些错误时,该命令会返回错误 (-1) 退出代码。 但即使某些图表包含一些错误, 所有 图表仍会生成,这对于大型项目来说可能是耗时的。

您可以使用 -failfast 标志来改变这种行为,在错误发生时尽快停止图表生成。在这种情况下,将生成一些图表,而有些图表则不会生成。

同时有 -failfast2 标志做第一次通过检查。 如果出现某些错误,根本不会有图表生成。如果有错误 -failfast2 运行速度比 -failfast 要快, 这可能对大型项目有用。。

 

 

标准输入输出

使用 -pipe 选项,您可以很容易在脚本中使用 PlantUML。

使用此选项,通过标准输入接收图表描述,并生成png文件到标准输出。在本地文件系统上不会写任何文件。

例如:

type somefile.txt | java -jar plantuml.jar -pipe > somefile.png

 

 

= 帮助 =

您可以用以下命令来获得帮助:

java -jar plantuml.jar -help

这将输出:

Usage: java -jar plantuml.jar [options] -gui
	(to execute the GUI)
	or java -jar plantuml.jar [options] [file/dir] [file/dir] [file/dir]
	(to process files or directories)

You can use the following wildcards in files/dirs:
	*	means any characters but '\'
	?	one and only one character but '\'
	**	means any characters (used to recurse through directories)

where options include:
	-gui			To run the graphical user interface
	-tpng			To generate images using PNG format (default)
	-tsvg			To generate images using SVG format
	-teps			To generate images using EPS format
	-tpdf			To generate images using PDF format
	-tvdx			To generate images using VDX format
	-txmi			To generate XMI file for class diagram
	-tscxml			To generate SCXML file for state diagram
	-thtml			To generate HTML file for class diagram
	-ttxt			To generate images with ASCII art
	-tutxt			To generate images with ASCII art using Unicode characters
	-tlatex			To generate images using LaTeX/Tikz format
	-tlatex:nopreamble		To generate images using LaTeX/Tikz format without preamble
	-o[utput] "dir"		To generate images in the specified directory
	-DVAR1=value		To set a preprocessing variable as if '!define VAR1 value' were used
	-Sparam1=value		To set a skin parameter as if 'skinparam param1 value' were used
	-r[ecurse]			recurse through directories
	-I/path/to/file		To include file as if '!include file' were used
	-I/path/to/*.puml		To include files with pattern
	-charset xxx		To use a specific charset (default is windows-1252)
	-e[x]clude pattern		To exclude files that match the provided pattern
	-metadata			To retrieve PlantUML sources from PNG images
	-checkmetadata		Skip PNG files that don't need to be regenerated
	-version			To display information about PlantUML and Java versions
	-checkversion		To check if a newer version is available for download
	-v[erbose]			To have log information
	-quiet			To NOT print error message into the console
	-keepfiles			To NOT delete temporary files after process
	-h[elp]			To display this help message
	-testdot			To test the installation of graphviz
	-graphvizdot "exe"		To specify dot executable
	-p[ipe]			To use stdin for PlantUML source and stdout for PNG/SVG/EPS generation
	-encodesprite 4|8|16[z] "file"	To encode a sprite at gray level (z for compression) from an image
	-computeurl|-encodeurl		To compute the encoded URL of a PlantUML source file
	-decodeurl			To retrieve the PlantUML source from an encoded URL
	-syntax			To report any syntax error from standard input without generating images
	-language			To print the list of PlantUML keywords
	-nosuggestengine		To disable the suggest engine when errors in diagrams
	-checkonly			To check the syntax of files without generating images
	-failfast			To stop processing as soon as a syntax error in diagram occurs
	-failfast2			To do a first syntax check before processing files, to fail even faster
	-pattern			To print the list of Regular Expression used by PlantUML
	-duration			To print the duration of complete diagrams processing
	-nbthread N			To use (N) threads for processing
	-nbthread auto		To use 4 threads for processing
	-author[s]			To print information about PlantUML authors
	-overwrite			To allow to overwrite read only files
	-printfonts			To print fonts available on your system
	-enablestats		To enable statistics computation
	-disablestats		To disable statistics computation (default)
	-htmlstats			To output general statistics in file plantuml-stats.html
	-xmlstats			To output general statistics in file plantuml-stats.xml
	-realtimestats		To generate statistics on the fly rather than at the end
	-loopstats			To continuously print statistics about usage
	-splash			To display a splash screen with some progress bar
	-progress			To display a textual progress bar in console
	-pipeimageindex N		To generate the Nth image with pipe option
	-stdlib			To print standart library info
	-extractstdlib		To extract PlantUML Standard Library into stdlib folder
	-filename \"example.puml\"	To override %filename% variable
	-preproc			To output preprocessor text of diagrams
	-cypher			To cypher texts of diagrams so that you can share them

If needed, you can setup the environment variable GRAPHVIZ_DOT.