### Install pip and tox Source: https://plantweb.readthedocs.io/_sources/developer.rst.txt Installs pip and tox using wget and python3. Ensure you have administrative privileges for system-wide installation. ```sh wget https://bootstrap.pypa.io/get-pip.py sudo python3 get-pip.py sudo pip3 install tox ``` -------------------------------- ### Install webdev for Local Serving Source: https://plantweb.readthedocs.io/_sources/developer.rst.txt Installs the webdev package, which is recommended for serving documentation locally. This simplifies the process of previewing documentation changes. ```sh sudo pip3 install webdev ``` -------------------------------- ### Install Plantweb using pip Source: https://plantweb.readthedocs.io/index.html Use this command to install the Plantweb package via pip. ```bash sudo pip3 install plantweb ``` -------------------------------- ### Render Graphviz file with Plantweb CLI Source: https://plantweb.readthedocs.io/index.html Example of rendering a Graphviz file using the Plantweb command-line interface. File extensions are irrelevant; Plantweb determines the engine based on content wrappers. ```dot @startdot digraph one_node_graph { node1 -> node2 -> node3 } @enddot ``` ```bash user@host:~$ plantweb mydotfile.dot ``` -------------------------------- ### Define a Graphviz file Source: https://plantweb.readthedocs.io/_sources/index.rst.txt Example of a Graphviz file content using the required @startdot and @enddot wrappers. ```text @startdot digraph one_node_graph { node1 -> node2 -> node3 } @enddot ``` -------------------------------- ### Define UML Diagram with Options Source: https://plantweb.readthedocs.io/index.html Example of a UML directive using alt, align, and target options. ```text .. uml:: :alt: This is a nice UML diagram. Indeed. :align: left :target: #options actor Foo1 boundary Foo2 control Foo3 entity Foo4 database Foo5 Foo1 -> Foo2 : To boundary Foo1 -> Foo3 : To control Foo1 -> Foo4 : To entity Foo1 -> Foo5 : To database ``` -------------------------------- ### Sequence Diagrams Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt Examples of interaction diagrams showing object communication order. ```PlantUML Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response ``` ```PlantUML actor Foo1 boundary Foo2 control Foo3 entity Foo4 database Foo5 Foo1 -> Foo2 : To boundary Foo1 -> Foo3 : To control Foo1 -> Foo4 : To entity Foo1 -> Foo5 : To database ``` ```PlantUML autonumber 10 10 "[000]" Bob -> Alice : Authentication Request Bob <- Alice : Authentication Response autonumber stop Bob -> Alice : dummy autonumber resume "Message 0 " Bob -> Alice : Yet another authentication Request Bob <- Alice : Yet another authentication Response autonumber stop Bob -> Alice : dummy autonumber resume 1 "Message 0 " Bob -> Alice : Yet another authentication Request Bob <- Alice : Yet another authentication Response ``` -------------------------------- ### Configure Git Pre-commit Hook Source: https://plantweb.readthedocs.io/_sources/developer.rst.txt Installs flake8 and pep8-naming, then configures the git pre-commit hook for code linting. This helps maintain code quality by enforcing style guides. ```sh sudo pip3 install flake8 pep8-naming flake8 --install-hook git config flake8.strict true ``` -------------------------------- ### Render PlantWeb File Source: https://plantweb.readthedocs.io/_sources/index.rst.txt Use the `render_file` function to render diagram content from a file. This example uses Graphviz engine and PNG format. ```python from plantweb.render import render_file CONTENT = """ digraph finite_state_machine { rankdir=LR; size="8,5" node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8; node [shape = circle]; LR_0 -> LR_2 [ label = "SS(B)" ]; LR_0 -> LR_1 [ label = "SS(S)" ]; LR_1 -> LR_3 [ label = "S($end)" ]; LR_2 -> LR_6 [ label = "SS(b)" ]; LR_2 -> LR_5 [ label = "SS(a)" ]; LR_2 -> LR_4 [ label = "S(A)" ]; LR_5 -> LR_7 [ label = "S(b)" ]; LR_5 -> LR_5 [ label = "S(a)" ]; LR_6 -> LR_6 [ label = "S(b)" ]; LR_6 -> LR_5 [ label = "S(a)" ]; LR_7 -> LR_8 [ label = "S(b)" ]; LR_7 -> LR_5 [ label = "S(a)" ]; LR_8 -> LR_6 [ label = "S(b)" ]; LR_8 -> LR_5 [ label = "S(a)" ]; } """ if __name__ == '__main__': infile = 'mygraph.dot' with open(infile, 'wb') as fd: fd.write(CONTENT.encode('utf-8')) print('==> INPUT FILE:') print(infile) outfile = render_file( infile, renderopts={ 'engine': 'graphviz', 'format': 'png' }, cacheopts={ 'use_cache': False } ) ``` -------------------------------- ### plantweb.directive Functions Source: https://plantweb.readthedocs.io/plantweb/plantweb.directive.html This section describes the functions available in the plantweb.directive module, including setup, event handlers, and default providers. ```APIDOC ## Functions in plantweb.directive ### `setup()` Setup function that makes this module a Sphinx extension. See http://www.sphinx-doc.org/en/stable/extdev/appapi.html#sphinx.application.Sphinx.add_config_value ### `builder_inited_handler(app)` We use this event handler to grab user defaults for Plantweb and use them in Plantweb rendering. See https://plantweb.readthedocs.io/index.html#overriding-defaults This is the handler of the ‘builder-inited’ event emitted by Sphinx. > Emitted when the builder object has been created. It is available as app.builder. See http://www.sphinx-doc.org/en/stable/extdev/appapi.html#event-builder-inited ### `defaults_provider()` Defaults provider that allows to register Sphinx user defaults. This dummy defaults provider just returns it’s attribute `overrides` if it exists. Returns: The dictionary of the form `DEFAULT_CONFIG`. Return type: dict ``` -------------------------------- ### Object Diagram Syntax Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt Displays instances and data values at a specific point in time. Useful for showing data structure examples. ```plantuml object Object01 Object01 : name = "Dummy" Object01 : id = 123 object Object02 object Object03 object Object04 object Object05 object Object06 object Object07 object Object08 Object01 <|-- Object02 Object03 *-- Object04 Object05 o-- "4" Object06 Object07 .. Object08 : some labels ``` -------------------------------- ### GET /defaults/providers Source: https://plantweb.readthedocs.io/_sources/plantweb/plantweb.defaults.rst.txt Retrieves the list of configuration providers used by the application. ```APIDOC ## GET /defaults/providers ### Description Retrieves the list of sources used to provide default configurations. ### Method GET ### Endpoint /defaults/providers ### Response #### Success Response (200) - **providers** (array) - A list of configuration provider URIs. #### Response Example [ "python://plantweb.defaults.DEFAULT_CONFIG", "file://~/.plantwebrc", "git://.plantwebrc" ] ``` -------------------------------- ### GET /defaults Source: https://plantweb.readthedocs.io/_sources/plantweb/plantweb.defaults.rst.txt Retrieves the default configuration values used by the plantweb application. ```APIDOC ## GET /defaults ### Description Retrieves the default configuration values for the plantweb application. ### Method GET ### Endpoint /defaults ### Response #### Success Response (200) - **cache_dir** (string) - The directory used for caching. - **engine** (string) - The default rendering engine. - **format** (string) - The default output format. - **server** (string) - The URL of the plantuml server. - **use_cache** (boolean) - Whether caching is enabled. #### Response Example { "cache_dir": "~/.cache/plantweb", "engine": "plantuml", "format": "svg", "server": "http://plantuml.com/plantuml/", "use_cache": true } ``` -------------------------------- ### Render PlantUML diagram using Sphinx directive Source: https://plantweb.readthedocs.io/index.html Example of using the `.. uml::` Sphinx directive to render PlantUML diagrams directly within reStructuredText. The `@startxxx`/`@endxxx` tags are not required when using directives. ```rst .. uml:: Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response ``` -------------------------------- ### View CLI help Source: https://plantweb.readthedocs.io/_sources/index.rst.txt Display the help menu for the Plantweb CLI. ```bash user@host:~$ plantweb --help usage: plantweb [-h] [-v] [--version] [--engine {auto,plantuml,graphviz,ditaa}] [--format {auto,svg,png}] [--server SERVER] [--no-cache] [--cache-dir CACHE_DIR] sources [sources ...] Python client for the PlantUML server positional arguments: sources source files to render optional arguments: -h, --help show this help message and exit -v, --verbose increase verbosity level --version show program's version number and exit --engine {auto,plantuml,graphviz,ditaa} engine to use to render diagram --format {auto,svg,png} diagram export format --server SERVER server to use for rendering --no-cache do not use cache --cache-dir CACHE_DIR directory to store cached renders ``` -------------------------------- ### Serve Documentation Locally Source: https://plantweb.readthedocs.io/_sources/developer.rst.txt Serves the built documentation using the webdev package. Point webdev to the directory containing the HTML output. ```sh $ webdev .tox/doc/tmp/html ``` -------------------------------- ### Build Documentation Source: https://plantweb.readthedocs.io/_sources/developer.rst.txt Builds the project documentation using tox. The output will be located in the .tox/doc/tmp/html directory. ```sh tox -e doc ``` -------------------------------- ### plantweb.main.main() Source: https://plantweb.readthedocs.io/plantweb/plantweb.main.html The main function serves as the application's entry point. ```APIDOC ## main() ### Description Application main function. ### Method N/A (Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **args** (argparse.Namespace) - Required - An arguments namespace. ### Request Example None ### Response #### Success Response (200) - **Exit code** (int) - The exit code of the application. #### Response Example None ``` -------------------------------- ### Plantweb CLI Help Source: https://plantweb.readthedocs.io/index.html Display the help message for the Plantweb command-line interface to see all available options. ```bash user@host:~$ plantweb --help usage: plantweb [-h] [-v] [--version] [--engine {auto,plantuml,graphviz,ditaa}] [--format {auto,svg,png}] [--server SERVER] [--no-cache] [--cache-dir CACHE_DIR] sources [sources ...] Python client for the PlantUML server positional arguments: sources source files to render optional arguments: -h, --help show this help message and exit -v, --verbose increase verbosity level --version show program's version number and exit --engine {auto,plantuml,graphviz,ditaa} engine to use to render diagram --format {auto,svg,png} diagram export format --server SERVER server to use for rendering --no-cache do not use cache --cache-dir CACHE_DIR directory to store cached renders ``` -------------------------------- ### Access DEFAULTS_PROVIDERS list Source: https://plantweb.readthedocs.io/_sources/plantweb/plantweb.defaults.rst.txt Displays the list of URI strings used to locate configuration files. ```guess ['python://plantweb.defaults.DEFAULT_CONFIG', 'file://~/.plantwebrc', 'git://.plantwebrc'] ``` -------------------------------- ### Render a diagram via CLI Source: https://plantweb.readthedocs.io/_sources/index.rst.txt Command to render a diagram file using the Plantweb CLI. ```bash user@host:~$ plantweb mydotfile.dot ``` -------------------------------- ### Engine Wrap String Mapping Source: https://plantweb.readthedocs.io/plantweb/plantweb.render.html A dictionary mapping engine names to their corresponding wrap strings used in @startXXX directives. ```python {'ditaa': 'ditaa', 'graphviz': 'dot', 'plantuml': 'uml'} ``` -------------------------------- ### State Diagram Syntax Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt Illustrates object states and transitions. Supports nested states and scale configuration. ```plantuml [*] --> State1 State1 --> [*] State1 : this is a string State1 : this is another string State1 -> State2 State2 --> [*] ``` ```plantuml scale 350 width [*] --> NotShooting state NotShooting { [*] --> Idle Idle --> Configuring : EvConfig Configuring --> Idle : EvConfig } state Configuring { [*] --> NewValueSelection NewValueSelection --> NewValuePreview : EvNewValue NewValuePreview --> NewValueSelection : EvNewValueRejected NewValuePreview --> NewValueSelection : EvNewValueSaved state NewValuePreview { State1 -> State2 } } ``` -------------------------------- ### Render a diagram with explicit engine Source: https://plantweb.readthedocs.io/_sources/index.rst.txt Use the --engine flag when the file lacks the @startxxx/@endxxx wrapper. ```bash user@host:~$ plantweb --engine=graphviz unwrappeddotfile.dot ``` -------------------------------- ### Render unwrapped Graphviz file with specified engine Source: https://plantweb.readthedocs.io/index.html If a file lacks the standard @startxxx/@endxxx wrappers, you can explicitly specify the engine using the --engine option. ```bash user@host:~$ plantweb --engine=graphviz unwrappeddotfile.dot ``` -------------------------------- ### Load UML diagram from file Source: https://plantweb.readthedocs.io/_sources/index.rst.txt Reference an external file for the diagram content within a Sphinx directive. ```rst .. uml:: my_uml_diagram.uml ``` -------------------------------- ### Configure Sphinx Extensions Source: https://plantweb.readthedocs.io/index.html Add the plantweb extension to the extensions list in conf.py. ```python extensions = [ # ... More extensions, 'plantweb.directive' ] ``` -------------------------------- ### Use Case Diagrams Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt Representations of user interactions with a system. ```PlantUML :Main Admin: as Admin (Use the application) as (Use) User <|-- Admin (Start) <|-- (Use) ``` ```PlantUML left to right direction skinparam packageStyle rect actor customer actor clerk rectangle checkout { customer -- (checkout) (checkout) .> (payment) : include (help) .> (checkout) : extends (checkout) -- clerk } ``` -------------------------------- ### Load UML diagram from absolute path Source: https://plantweb.readthedocs.io/_sources/index.rst.txt Reference a file using an absolute path from the Sphinx documentation root. ```rst .. uml:: /diagrams/my_uml_diagram.uml ``` -------------------------------- ### render_file Source: https://plantweb.readthedocs.io/_sources/plantweb/plantweb.render.rst.txt Renders a specified PlantUML, Graphviz, or DITAA file. ```APIDOC ## render_file ### Description Render given PlantUML, Graphviz or DITAA file. ### Parameters - **path** (string) - Required - The path to the file to be rendered. ``` -------------------------------- ### Define .plantwebrc Configuration Source: https://plantweb.readthedocs.io/index.html JSON configuration file for overriding default settings. ```json { "server": "http://mydomain.com/plantuml/", "cache_dir": "~/.cache/plantweb", "engine": "plantuml", "format": "svg", "use_cache": true } ``` -------------------------------- ### plantweb.render.WRAP_STR Source: https://plantweb.readthedocs.io/plantweb/plantweb.render.html A dictionary mapping engine names to their corresponding wrap strings used in the `@startXXX` directive. ```APIDOC ## GET /WRAP_STR ### Description Get the mapping between engine names and their wrap strings. ### Method GET ### Endpoint /WRAP_STR ### Response #### Success Response (200) - **WRAP_STR** (dict) - Map between the name of the engine and the wrap string used in the `@startXXX` directive. ### Response Example { "WRAP_STR": { "ditaa": "ditaa", "graphviz": "dot", "plantuml": "uml" } } ``` -------------------------------- ### render Source: https://plantweb.readthedocs.io/_sources/plantweb/plantweb.render.rst.txt Renders provided PlantUML, Graphviz, or DITAA content directly. ```APIDOC ## render ### Description Render given PlantUML, Graphviz or DITAA content. ### Parameters - **content** (string) - Required - The raw diagram content to render. ``` -------------------------------- ### Activity Diagrams Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt Graphical representations of workflows and stepwise activities. ```PlantUML start :Hello world; :This is on defined on several **lines**; stop ``` ```PlantUML start if (condition A) then (yes) :Text 1; elseif (condition B) then (yes) :Text 2; stop elseif (condition C) then (yes) :Text 3; elseif (condition D) then (yes) :Text 4; else (nothing) :Text else; endif ``` ```PlantUML start if (multiprocessor?) then (yes) fork :Treatment 1; fork again ``` -------------------------------- ### plantweb.render.render_file Source: https://plantweb.readthedocs.io/plantweb/plantweb.render.html Renders a given PlantUML, Graphviz, or DITAA file to an output file. ```APIDOC ## POST /render_file ### Description Render given PlantUML, Graphviz or DITAA file. ### Method POST ### Endpoint /render_file ### Parameters #### Request Body - **infile** (str) - Required - Path to source file to render. - **outfile** (str) - Optional - Path to output file. If `None`, the filename will be auto-determined and saved to the current working directory. - **renderopts** (dict) - Optional - Rendering options (`engine`, `format` and `server`) as in `render()`. - **cacheopts** (dict) - Optional - Caching options (`use_cache` and `cache_dir`) as in `render()`. ### Response #### Success Response (200) - **output_path** (str) - Path to output file. ### Response Example { "output_path": "/path/to/output/file.png" } ``` -------------------------------- ### Run Test Suite Source: https://plantweb.readthedocs.io/_sources/developer.rst.txt Executes the project's test suite using tox for Python 2.7 and Python 3.4 environments. This command verifies the functionality of the codebase. ```sh tox -e py27,py34 ``` -------------------------------- ### Run PlantUML Server with Docker Source: https://plantweb.readthedocs.io/index.html Use these Docker commands to pull the PlantUML server image and run it in detached mode, publishing port 8080. ```bash docker pull plantuml/plantuml-server ``` ```bash docker run --detach --publish 8080:8080 plantuml/plantuml-server ``` -------------------------------- ### Component Diagram Syntax Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt Defines component relationships and wiring. Use these to illustrate the structure of complex systems. ```plantuml DataAccess - [First Component] [First Component] ..> HTTP : use ``` ```plantuml package "Some Group" { HTTP - [First Component] [Another Component] } node "Other Groups" { FTP - [Second Component] [First Component] --> FTP } cloud { [Example 1] } database "MySql" { folder "This is my folder" { [Folder 3] } frame "Foo" { [Frame 4] } } [Another Component] --> [Example 1] [Example 1] --> [Folder 3] [Folder 3] --> [Frame 4] ``` -------------------------------- ### plantweb.render.render Source: https://plantweb.readthedocs.io/plantweb/plantweb.render.html Renders given PlantUML, Graphviz, or DITAA content. ```APIDOC ## POST /render ### Description Render given PlantUML, Graphviz or DITAA content. ### Method POST ### Endpoint /render ### Parameters #### Request Body - **content** (str) - Required - Content to render. - **engine** (str) - Optional - Engine to use to render the content. One of `'plantuml'`, `'graphviz'` or `'ditaa'`. If `None`, the engine will be auto-determined by looking into the content for the `@startxxxx` tags, and if unable to be auto-determined the default engine will be used. - **format** (str) - Optional - Format of the rendered content. Raster `png` or vector `svg`. Please note that engine `ditaa` can only render to `png`. If `None`, the default format will always be selected unless the engine doesn’t supports it. - **server** (str) - Optional - URL to PlantUML server. This will passed as is to `render_cached()`. If `None` the default server URL will be used. - **cacheopts** (dict) - Optional - Caching options (`use_cache` and `cache_dir`) as in `render()`. ### Response #### Success Response (200) - **output** (bytes) - The bytes of the rendered output. - **format** (str) - The name of the output format. - **engine** (str) - The name of the engine used or detected. - **sha** (str) - The sha256 hash for identifying the cache file. ### Response Example { "output": "base64_encoded_image_data", "format": "png", "engine": "plantuml", "sha": "abcdef1234567890" } ``` -------------------------------- ### plantweb.render.render Source: https://plantweb.readthedocs.io/_sources/index.rst.txt Renders diagram content directly from a string. ```APIDOC ## render(content, engine, format, cacheopts) ### Description Allows to render diagram content directly from a string input. ### Parameters - **content** (string) - Required - The diagram definition content. - **engine** (string) - Optional - The rendering engine to use (e.g., 'plantuml'). - **format** (string) - Optional - The output format (e.g., 'svg'). - **cacheopts** (dict) - Optional - Configuration for caching, e.g., {'use_cache': False}. ### Response - **output** (string) - The rendered diagram data. ``` -------------------------------- ### Access DEFAULT_CONFIG values Source: https://plantweb.readthedocs.io/_sources/plantweb/plantweb.defaults.rst.txt Displays the default configuration dictionary used by plantweb. ```guess {'cache_dir': '~/.cache/plantweb', 'engine': 'plantuml', 'format': 'svg', 'server': 'http://plantuml.com/plantuml/', 'use_cache': True} ``` -------------------------------- ### Render File with Python API Source: https://plantweb.readthedocs.io/index.html Use the render_file function to process a diagram file. ```python from plantweb.render import render_file CONTENT = """ digraph finite_state_machine { rankdir=LR; size="8,5" node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8; node [shape = circle]; LR_0 -> LR_2 [ label = "SS(B)" ]; LR_0 -> LR_1 [ label = "SS(S)" ]; LR_1 -> LR_3 [ label = "S($end)" ]; LR_2 -> LR_6 [ label = "SS(b)" ]; LR_2 -> LR_5 [ label = "SS(a)" ]; LR_2 -> LR_4 [ label = "S(A)" ]; LR_5 -> LR_7 [ label = "S(b)" ]; LR_5 -> LR_5 [ label = "S(a)" ]; LR_6 -> LR_6 [ label = "S(b)" ]; LR_6 -> LR_5 [ label = "S(a)" ]; LR_7 -> LR_8 [ label = "S(b)" ]; LR_7 -> LR_5 [ label = "S(a)" ]; LR_8 -> LR_6 [ label = "S(b)" ]; LR_8 -> LR_5 [ label = "S(a)" ]; } """ if __name__ == '__main__': infile = 'mygraph.dot' with open(infile, 'wb') as fd: fd.write(CONTENT.encode('utf-8')) print('==> INPUT FILE:') print(infile) outfile = render_file( infile, renderopts={ 'engine': 'graphviz', 'format': 'png' }, cacheopts={ 'use_cache': False } ) print('==> OUTPUT FILE:') print(outfile) ``` -------------------------------- ### plantweb.plantuml.plantuml Source: https://plantweb.readthedocs.io/plantweb/plantweb.plantuml.html This function allows you to call the PlantUML server to render content. ```APIDOC ## plantweb.plantuml.plantuml ### Description Call the PlantUML server. ### Method POST ### Endpoint /plantuml ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **server** (str) - Required - Base URL for the server. - **extension** (str) - Required - File format / extension to use for the request. - **content** (str) - Required - Content to render. ### Request Example ```json { "server": "http://www.plantuml.com/plantuml", "extension": "png", "content": "@startuml\nAlice -> Bob: Hello Bob\n@enduml" } ``` ### Response #### Success Response (200) - **response** (str) - The response from the PlantUML server, typically the rendered image or a success message. #### Response Example ```json { "response": "... (image data or success message) ..." } ``` ``` -------------------------------- ### Determine Rendering Engine Source: https://plantweb.readthedocs.io/plantweb/plantweb.render.html Identifies the rendering engine based on the @startXXX tag present in the content. ```text @startuml --> plantuml @startdot --> graphviz @startditaa --> ditaa ``` -------------------------------- ### Apache License 2.0 Source: https://plantweb.readthedocs.io/index.html The license governs the use of the software, outlining permissions and limitations. ```text Copyright (C) 2016-2017 Carlos Jenkins Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### Class Diagrams Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt Static structure diagrams showing classes, attributes, and relationships. ```PlantUML class Foo1 { You can use several lines .. as you want and group == things together. __ You can have as many groups as you want -- End of class } class User { .. Simple Getter .. + getName() + getAddress() .. Some setter .. + setName() __ private data __ int age -- encrypted -- String password } ``` ```PlantUML package "Classic Collections" #DDDDDD { Object <|-- ArrayList } package net.sourceforge.plantuml { Object <|-- Demo1 Demo1 *- Demo2 } package foo6 <> { class Class6 } ``` -------------------------------- ### Graphviz Cluster Diagram Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt Demonstrates drawing nodes and edges in clusters using subgraphs. Clusters are identified by the 'cluster' prefix in the subgraph name. ```graphviz digraph G { subgraph cluster_0 { style=filled; color=lightgrey; node [style=filled,color=white]; a0 -> a1 -> a2 -> a3; label = "process #1"; } subgraph cluster_1 { node [style=filled]; b0 -> b1 -> b2 -> b3; label = "process #2"; color=blue } start -> a0; start -> b0; a1 -> b3; b2 -> a3; a3 -> a0; a3 -> end; b3 -> end; start [shape=Mdiamond]; end [shape=Msquare]; } ``` -------------------------------- ### Set Plantweb Defaults in Sphinx Source: https://plantweb.readthedocs.io/index.html Define the plantweb_defaults dictionary in conf.py to configure the extension. ```python # Plantweb configuration plantweb_defaults = { 'server': 'http://myserver.com/plantuml/' } ``` -------------------------------- ### plantweb.defaults.read_defaults() Source: https://plantweb.readthedocs.io/plantweb/plantweb.defaults.html Retrieves the default configuration values for Plantweb. It can optionally read from a cache or determine defaults from a list of providers. ```APIDOC ## GET plantweb.defaults.read_defaults() ### Description Get the defaults values. ### Method GET ### Endpoint plantweb.defaults.read_defaults ### Parameters #### Query Parameters - **cached** (bool) - Optional - Read cached default values or determine them from the list of providers. See `DEFAULTS_PROVIDERS`. ### Response #### Success Response (200) - **dict** - A dictionary like `DEFAULT_CONFIG` with the user defaults. ### Response Example ```json { "cache_dir": "~/.cache/plantweb", "engine": "plantuml", "format": "svg", "server": "http://plantuml.com/plantuml/", "use_cache": true } ``` ``` -------------------------------- ### Render Content with Python API Source: https://plantweb.readthedocs.io/index.html Use the render function to process diagram content directly from a string. ```python from plantweb.render import render CONTENT = """ actor Foo1 boundary Foo2 control Foo3 entity Foo4 database Foo5 Foo1 -> Foo2 : To boundary Foo1 -> Foo3 : To control Foo1 -> Foo4 : To entity Foo1 -> Foo5 : To database """ if __name__ == '__main__': print('==> INPUT:') print(CONTENT) output = render( CONTENT, engine='plantuml', format='svg', cacheopts={ 'use_cache': False } ) print('==> OUTPUT:') print(output) ``` -------------------------------- ### Load PlantUML diagram content from a file in Sphinx Source: https://plantweb.readthedocs.io/index.html Sphinx directives support loading diagram content from an external file. Specify the file path relative to the current document or the Sphinx documentation root. ```rst .. uml:: my_uml_diagram.uml ``` ```rst .. uml:: /diagrams/my_uml_diagram.uml ``` -------------------------------- ### Function: parse_args Source: https://plantweb.readthedocs.io/plantweb/plantweb.args.html The parse_args function handles the parsing and verification of command-line arguments for the Plantweb client. ```APIDOC ## Function: plantweb.args.parse_args ### Description Argument parsing routine for the Plantweb client. ### Parameters #### Arguments - **argv** (list) - Optional - A list of argument strings. ### Returns - **Namespace** (argparse.Namespace) - A parsed and verified arguments namespace. ``` -------------------------------- ### plantweb.defaults.DEFAULTS_PROVIDERS Source: https://plantweb.readthedocs.io/plantweb/plantweb.defaults.html A list of providers for default configuration values, ordered by priority. Later providers override earlier ones. ```APIDOC ## GET plantweb.defaults.DEFAULTS_PROVIDERS ### Description List of defaults providers ordered by read priority. Last items will be processed last and thus will override previous values. ### Method GET ### Endpoint plantweb.defaults.DEFAULTS_PROVIDERS ### Available Providers - `git://` Will fetch the repository root from current working directory using git’s `git rev-parse --show-toplevel` and then read the specified file from that path. - `file://` Will read the file specified. User expansion `~` is supported. - `python://` Will import the given variable or function: * If a function, it will be executed without arguments and its result will be used. * If a variable, it must be a dictionary similar to `DEFAULT_CONFIG`. ### Response #### Success Response (200) - **list** - A list of strings, where each string is a provider URI. ### Response Example ```json [ "python://plantweb.defaults.DEFAULT_CONFIG", "file://~/.plantwebrc", "git://.plantwebrc" ] ``` ``` -------------------------------- ### Apply Responsive Image CSS Source: https://plantweb.readthedocs.io/index.html CSS snippet to ensure SVG and image elements remain responsive within the container. ```css /* Responsive images */ object[type="image/svg+xml"], img { max-width: 100%; height: auto; } ``` -------------------------------- ### Plantweb Module Index Source: https://plantweb.readthedocs.io/genindex.html This section lists the modules available within the plantweb package. ```APIDOC ## Plantweb Modules This documentation provides an overview of the modules within the plantweb package. ### Modules - plantweb.args - plantweb.defaults - plantweb.directive - plantweb.main - plantweb.plantuml - plantweb.render ``` -------------------------------- ### Plantweb Render API Source: https://plantweb.readthedocs.io/genindex.html Details about the functions and constants within the plantweb.render module. ```APIDOC ## plantweb.render API ### Constants - **WRAP_STR** ### Functions - **determine_engine()** - **render()** - **render_cached()** - **render_file()** ``` -------------------------------- ### plantweb.defaults.DEFAULT_CONFIG Source: https://plantweb.readthedocs.io/plantweb/plantweb.defaults.html The default configuration dictionary for plantweb. This configuration is used when no engine is specified and cannot be auto-determined. ```APIDOC ## GET plantweb.defaults.DEFAULT_CONFIG ### Description Default configuration for plantweb. ### Method GET ### Endpoint plantweb.defaults.DEFAULT_CONFIG ### Notes The default engine will be used only when the engine was unset and it was unable to be auto-determined. To set a different default configuration create a JSON file `.plantwebrc` in your git repository root or in your home, as defined in `DEFAULTS_PROVIDERS`. ### Response #### Success Response (200) - **dict** - Default configuration settings. ### Response Example ```json { "cache_dir": "~/.cache/plantweb", "engine": "plantuml", "format": "svg", "server": "http://plantuml.com/plantuml/", "use_cache": true } ``` ``` -------------------------------- ### Plantweb Args API Source: https://plantweb.readthedocs.io/genindex.html Details about the parse_args function within the plantweb.args module. ```APIDOC ## plantweb.args API ### Functions - **parse_args()** ``` -------------------------------- ### Ditaa ASCII Diagrams Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt A collection of ASCII-based diagrams rendered using Ditaa. ```ditaa +--------+ +-------+ +-------+ | +---+ ditaa +--> | | | Text | +-------+ |diagram| |Document| |!magic!| | | | {d}| | | | | +---+----+ +-------+ +-------+ : ^ | Lots of work | +-------------------------+ ``` ```ditaa /--------\ +-------+ |cAAA +---+Version| | Data | | V3 | | Base | |cRED{d}| | {s}| +-------+ \---+----/ ``` ```ditaa +---+-----+ +----------+ | cBLU | | {io} | | Ext-Foo | | S-ATA | | +-----+ | cFEA | | |cPNK | +----------+ | | Foo | +---+-----+ ``` ```ditaa /-------------+-------------\ |cRED RED |cBLU BLU | +-------------+-------------+ |cGRE GRE |cPNK PNK | +-------------+-------------+ |cAAA AAA | +-------------+-------------+ |cCCC CCC | +-------------+-------------+ |cBLK BLK |cYEL YEL | \-------------+-------------/ ``` ```ditaa +---------------+ +----------+ | This was | | And it is| | created with +-----------+---------->+ great! | | asciiflow.com | | | | +---------------+ | +----------+ | | +-----------+ | | | | ``` -------------------------------- ### Use UML directive in Sphinx Source: https://plantweb.readthedocs.io/_sources/index.rst.txt Embed PlantUML diagrams directly in Sphinx documentation using the .. uml:: directive. ```rst .. uml:: Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response ``` -------------------------------- ### Engine Mapping for plantweb.render Source: https://plantweb.readthedocs.io/_sources/plantweb/plantweb.render.rst.txt This dictionary maps engine names to their corresponding identifiers used within the plantweb.render module. It is used internally to process different diagram types. ```guess { 'ditaa': 'ditaa', 'graphviz': 'dot', 'plantuml': 'uml' } ``` -------------------------------- ### Plantweb Defaults API Source: https://plantweb.readthedocs.io/genindex.html Details about the constants and functions within the plantweb.defaults module. ```APIDOC ## plantweb.defaults API ### Constants - **DEFAULT_CONFIG** - **DEFAULTS_PROVIDERS** ### Functions - **read_defaults()** ``` -------------------------------- ### Plantweb Main API Source: https://plantweb.readthedocs.io/genindex.html Details about the main function within the plantweb.main module. ```APIDOC ## plantweb.main API ### Functions - **main()** ``` -------------------------------- ### determine_engine Source: https://plantweb.readthedocs.io/_sources/plantweb/plantweb.render.rst.txt Identifies the rendering engine required for the provided content. ```APIDOC ## determine_engine ### Description Determine the engine used in the given content. ### Parameters - **content** (string) - Required - The content to analyze for engine determination. ``` -------------------------------- ### Run Coverage Test Source: https://plantweb.readthedocs.io/_sources/developer.rst.txt Generates a code coverage report using tox. This helps identify areas of the code that are not adequately tested. ```sh tox -e coverage ``` -------------------------------- ### Plantweb Directive API Source: https://plantweb.readthedocs.io/genindex.html Details about the classes and functions within the plantweb.directive module. ```APIDOC ## plantweb.directive API ### Classes - **DiagramDirective** - **GraphDirective** - **Plantweb** - **UmlDirective** ### Functions - **builder_inited_handler()** ``` -------------------------------- ### plantweb.render.render_cached Source: https://plantweb.readthedocs.io/plantweb/plantweb.render.html Renders given content in the PlantUML server or fetches it from cache. ```APIDOC ## POST /render_cached ### Description Render given content in the PlantUML server or fetch it from cache. ### Method POST ### Endpoint /render_cached ### Parameters #### Request Body - **server** (str) - Required - URL to PlantUML server. - **format** (str) - Required - File format to render the content. One of the supported by the PlantUML server (`svg` or `png`). - **content** (str) - Required - Content to render with mandatory `@startxxx` tags. - **use_cache** (bool) - Optional - Use local cache to avoid requesting the server for already rendered diagrams. If `None`, the default value will be used. - **cache_dir** (str) - Optional - Directory to store the cached diagrams. If `None` the default value will be used. ### Response #### Success Response (200) - **content** (bytes) - The bytes of the rendered content. - **sha** (str) - A sha256 hash string identifying the content. ### Response Example { "content": "base64_encoded_image_data", "sha": "abcdef1234567890" } ``` -------------------------------- ### plantweb.directive Classes Source: https://plantweb.readthedocs.io/plantweb/plantweb.directive.html This section describes the classes available in the plantweb.directive module, which are specialized directives for rendering different types of diagrams. ```APIDOC ## Classes in plantweb.directive ### `Plantweb` FIXME: Document. Inheritance: Inheritance diagram of Plantweb ### `UmlDirective` Specialized `uml` directive for Plantweb `Plantweb` engine. See `Plantweb`. Inheritance: Inheritance diagram of UmlDirective ### `GraphDirective` Specialized `graph` directive for Plantweb `graphviz` engine. See `Plantweb`. Inheritance: Inheritance diagram of GraphDirective ### `DiagramDirective` Specialized `diagram` directive for Plantweb `ditaa` engine. See `Plantweb`. Inheritance: Inheritance diagram of DiagramDirective ``` -------------------------------- ### render_cached Source: https://plantweb.readthedocs.io/_sources/plantweb/plantweb.render.rst.txt Renders content using the PlantUML server or retrieves it from the cache. ```APIDOC ## render_cached ### Description Render given content in the PlantUML server or fetch it from cache. ### Parameters - **content** (string) - Required - The diagram content to render or retrieve from cache. ``` -------------------------------- ### plantweb.render.determine_engine Source: https://plantweb.readthedocs.io/plantweb/plantweb.render.html Determines the rendering engine used in the given content based on `@startXXX` tags. ```APIDOC ## POST /determine_engine ### Description Determine the engine used in the given content. ### Method POST ### Endpoint /determine_engine ### Parameters #### Request Body - **content** (str) - Required - Content to analyze. ### Response #### Success Response (200) - **engine** (str) - The name of the engine found, or None. ### Response Example { "engine": "plantuml" } ``` -------------------------------- ### Plantweb PlantUML API Source: https://plantweb.readthedocs.io/genindex.html Details about the plantuml function within the plantweb.plantuml module. ```APIDOC ## plantweb.plantuml API ### Functions - **plantuml()** ``` -------------------------------- ### Graphviz Finite State Machine Digraph Source: https://plantweb.readthedocs.io/_sources/examples.rst.txt A directed graph representing a finite state machine with specific node shapes and edge labels. ```graphviz digraph finite_state_machine { rankdir=LR; size="8,5" node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8; node [shape = circle]; LR_0 -> LR_2 [ label = "SS(B)" ]; LR_0 -> LR_1 [ label = "SS(S)" ]; LR_1 -> LR_3 [ label = "S($end)" ]; LR_2 -> LR_6 [ label = "SS(b)" ]; LR_2 -> LR_5 [ label = "SS(a)" ]; LR_2 -> LR_4 [ label = "S(A)" ]; LR_5 -> LR_7 [ label = "S(b)" ]; LR_5 -> LR_5 [ label = "S(a)" ]; LR_6 -> LR_6 [ label = "S(b)" ]; LR_6 -> LR_5 [ label = "S(a)" ]; LR_7 -> LR_8 [ label = "S(b)" ]; LR_7 -> LR_5 [ label = "S(a)" ]; LR_8 -> LR_6 [ label = "S(b)" ]; LR_8 -> LR_5 [ label = "S(a)" ]; } ```