Шаблон:Plantuml

Материал из свободной русской энциклопедии «Традиция»
Перейти к навигации Перейти к поиску

{{Plantuml}} — шаблон для вывода диаграмм UML, отрисованных программой PlantUML, использующий функциональность расширения MediaWiki ExternalData.

Параметры:

  1. или uml — описание диаграммы на языке PlantUML. Если в описании присутсвует знак равенства, потребуется использовать синтаксис именованного параметра (1= или uml=). Если имеется символ |, его надо заменить на {{!}},
  • id — уникальный идентификатор диаграммы на странице. Его желательно использовать, если на странице есть другие диаграммы.

Примеры[править код]

Описание Викитекст Вывод
Пример 1
{{plantuml|id=e1|uml=
@startuml
actor Foo1
boundary Foo2
control Foo3
entity Foo4
database Foo5
collections Foo6
Foo1 -> Foo2 : To boundary
Foo1 -> Foo3 : To control
Foo1 -> Foo4 : To entity
Foo1 -> Foo5 : To database
Foo1 -> Foo6 : To collections
@enduml
}}

Foo1Foo1Foo2Foo2Foo3Foo3Foo4Foo4Foo5Foo5Foo6Foo6To boundaryTo controlTo entityTo databaseTo collections

Пример 2
{{plantuml|id=e2|uml=
@startuml
Alice -> Bob: Authentication Request
Bob -> Alice: Authentication Failure
group My own label [My own label 2]
Alice -> Log : Log attack start
loop 1000 times
Alice -> Bob: DNS Attack
end
Alice -> Log : Log attack end
end
@enduml
}}

AliceAliceBobBobLogLogAuthentication RequestAuthentication FailureMy own label[My own label 2]Log attack startloop[1000 times]DNS AttackLog attack end

Пример 3
{{plantuml|id=e3|uml=
@startuml
title Servlet Container
(*) --> "ClickServlet.handleRequest()"
--> "new Page"
if "Page.onSecurityCheck" then
->[true] "Page.onInit()"
if "isForward?" then
->[no] "Process controls"
if "continue processing?" then
-->[yes] ===RENDERING===
else
-->[no] ===REDIRECT_CHECK===
endif
else
-->[yes] ===RENDERING===
endif
if "is Post?" then
-->[yes] "Page.onPost()"
--> "Page.onRender()" as render
--> ===REDIRECT_CHECK===
else
-->[no] "Page.onGet()"
--> render
endif
else
-->[false] ===REDIRECT_CHECK===
endif
if "Do redirect?" then
->[yes] "redirect request"
--> ==BEFORE_DESTROY===
else
if "Do Forward?" then
-left->[yes] "Forward request"
--> ==BEFORE_DESTROY===
else
-right->[no] "Render page template"
--> ==BEFORE_DESTROY===
endif
endif
--> "Page.onDestroy()"
-->(*)
@enduml
}}

Servlet ContainerClickServlet.handleRequest()new PagePage.onInit()Process controlsPage.onPost()Page.onRender()Page.onGet()redirect requestForward requestRender page templatePage.onDestroy()Page.onSecurityChecktrueisForward?nocontinue processing?yesnoyesis Post?yesnofalseDo redirect?yesDo Forward?yesno

Пример 4
{{plantuml|id=e4|uml=
10.17 Digital Example 10 TIMING DIAGRAM
concise "Response freshness" as Cache
Server is idle
Client is idle
@Client
0 is send
Client -> Server@+25 : GET
+25 is await
+75 is recv
+25 is idle
+25 is send
Client -> Server@+25 : GET\nIf-Modified-Since: 150
+25 is await
+50 is recv
+25 is idle
@100 <-> @275 : no need to re-request from server
@Server
25 is recv
+25 is work
+25 is send
Server -> Client@+25 : 200 OK\nExpires: 275
+25 is idle
+75 is recv
+25 is send
Server -> Client@+25 : 304 Not Modified
+25 is idle
@Cache
75 is fresh
+200 is stale
@enduml
10.17 Digital Example
@startuml
scale 5 as 150 pixels
clock clk with period 1
binary "enable" as en
binary "R/W" as rw
binary "data Valid" as dv
concise "dataBus" as db
concise "address bus" as addr
@6 as :write_beg
@10 as :write_end
@15 as :read_beg
@19 as :read_end
@0
en is low
db is "0x0"
addr is "0x03f"
rw is low
dv is 0
@:write_beg-3
en is high
@:write_beg-2
db is "0xDEADBEEF"
@:write_beg-1
dv is 1
@:write_beg
rw is high
@:write_end
rw is low
dv is low
@:write_end+1
rw is low
db is "0x0"
addr is "0x23"
@12
dv is high
@13
db is "0xFFFF"
@20
en is low
dv is low
@21
db is "0x0"
highlight :write_beg to :write_end #Gold:Write
highlight :read_beg to :read_end #lightBlue:Read
db@:write_beg-1 <-> @:write_end : setup time
db@:write_beg-1 -> addr@:write_end+1 : hold
@enduml
}}

enableR/Wdata ValiddataBus0x00xDEADBEEF0x00xFFFF0x0setup timeaddress bus0x03f0x230510152025holdWriteRead

Пример 5
{{plantuml|@startuml
:<latex>\int_0^1f(x)dx</latex>;
:<latex>x^2+y_1+z_{12}^{34}</latex>;
note right
Try also
<latex>\dfrac{d}{dx}f(x){{=}}\lim\limits_{h \to 0}\dfrac{f(x+h)-f(x)}{h}</latex>
<latex>P(y{{!}}\mathbf{x}) \mbox{ or } f(\mathbf{x})+\epsilon</latex>
end note
@enduml}}
Try also

Настройки вики[править код]

Для работы шаблон требует установки расширения MediaWiki ExternalData, программы PlantUML и настроек в LocalSettings.php:

// sudo wget https://downloads.sourceforge.net/project/plantuml/plantuml.jar -P /usr/share/java
// wget http://beta.plantuml.net/plantuml-jlatexmath.zip && sudo unzip plantuml-jlatexmath.zip -d /usr/share/java
$wgExternalDataSources['plantuml'] = [
	'name'			=> 'PlantUML',
	'program url'	=> 'https://plantuml.com',
	'version command'=> 'java -jar /usr/share/java/plantuml.jar -version',
	'command'		=> 'java -jar /usr/share/java/plantuml.jar -tsvg -charset UTF-8 -p',
	'env'			=> [ 'LOG4J_FORMAT_MSG_NO_LOOKUPS' => true ],
	'program limits'=> [ 'memory' => 0 ],
	'input'			=> 'uml',
	'preprocess'	=> 'EDConnectorExe::wikilinks4uml',
	'postprocess'	=> 'EDConnectorExe::innerXML',
	'tag'			=> 'plantuml'
];

Ссылки[править код]