Doxygen
Loading...
Searching...
No Matches
mermaid.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2026 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef MERMAID_H
17#define MERMAID_H
18
19#include <map>
20#include <string>
21#include <vector>
22
23#include "containers.h"
24#include "qcstring.h"
25
27{
28 MermaidDiagramInfo(const QCString &baseName_, const QCString &content_,
29 const QCString &outDir_, const QCString &srcFile_, int srcLine_)
30 : baseName(baseName_), content(content_), outDir(outDir_),
31 srcFile(srcFile_), srcLine(srcLine_) {}
37};
38
39/** Singleton that manages Mermaid diagram rendering via the mmdc CLI tool. */
41{
42 public:
43 /** Mermaid output image formats */
44 enum class OutputFormat { HTML, LaTeX, RTF, Docbook };
45 enum class ImageFormat { PNG, SVG, PDF };
46
47 static MermaidManager &instance();
48
49 /** Run mmdc tool for all collected diagrams */
50 void run();
51
52 /** Write a Mermaid source file and register it for CLI rendering.
53 * @param[in] outDirArg the output directory to write the file to.
54 * @param[in] fileName the name of the file. If empty a name will be chosen automatically.
55 * @param[in] content the Mermaid diagram source.
56 * @param[in] format the image format to generate.
57 * @param[in] srcFile the source file resulting in the write command.
58 * @param[in] srcLine the line number resulting in the write command.
59 * @returns The base name of the generated file (without extension).
60 */
61 QCString writeMermaidSource(const QCString &outDirArg, const QCString &fileName,
62 const QCString &content, ImageFormat format,
63 const QCString &srcFile, int srcLine);
64
65 /** Register a generated Mermaid image with the index.
66 * @param[in] baseName the name of the generated file (as returned by writeMermaidSource())
67 * @param[in] outDir the directory containing the resulting image.
68 * @param[in] format the image format that was generated.
69 * @param[in] toIndex add the file to the index lists for htmlhelp / qhc etc.
70 */
71 void generateMermaidOutput(const QCString &baseName, const QCString &outDir, ImageFormat format, bool toIndex);
72
79 using DiagramList = std::vector<MermaidDiagram>;
80
81 static QCString imageExtension(ImageFormat imageFormat);
83
84 private:
86
88};
89
90#endif
Singleton that manages Mermaid diagram rendering via the mmdc CLI tool.
Definition mermaid.h:41
void run()
Run mmdc tool for all collected diagrams.
Definition mermaid.cpp:245
OutputFormat
Mermaid output image formats.
Definition mermaid.h:44
void generateMermaidOutput(const QCString &baseName, const QCString &outDir, ImageFormat format, bool toIndex)
Register a generated Mermaid image with the index.
Definition mermaid.cpp:117
static QCString imageExtension(ImageFormat imageFormat)
Definition mermaid.cpp:43
static MermaidManager & instance()
Definition mermaid.cpp:33
DiagramList m_diagrams
Definition mermaid.h:87
static ImageFormat convertToImageFormat(OutputFormat outputFormat)
Definition mermaid.cpp:54
std::vector< MermaidDiagram > DiagramList
Definition mermaid.h:79
QCString writeMermaidSource(const QCString &outDirArg, const QCString &fileName, const QCString &content, ImageFormat format, const QCString &srcFile, int srcLine)
Write a Mermaid source file and register it for CLI rendering.
Definition mermaid.cpp:70
This is an alternative implementation of QCString.
Definition qcstring.h:101
Definition message.h:144
QCString srcFile
Definition mermaid.h:35
MermaidDiagramInfo(const QCString &baseName_, const QCString &content_, const QCString &outDir_, const QCString &srcFile_, int srcLine_)
Definition mermaid.h:28
QCString content
Definition mermaid.h:33
QCString baseName
Definition mermaid.h:32
QCString outDir
Definition mermaid.h:34
MermaidDiagramInfo info
Definition mermaid.h:77
MermaidDiagram(ImageFormat fmt, MermaidDiagramInfo &&inf)
Definition mermaid.h:75