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
50 bool hasInlineDiagrams() const { return m_hasInlineDiagrams; }
51
52 /** Run mmdc tool for all collected diagrams */
53 void run();
54
55 /** Write a Mermaid source file and register it for CLI rendering.
56 * @param[in] outDirArg the output directory to write the file to.
57 * @param[in] fileName the name of the file. If empty a name will be chosen automatically.
58 * @param[in] content the Mermaid diagram source.
59 * @param[in] format the image format to generate.
60 * @param[in] srcFile the source file resulting in the write command.
61 * @param[in] srcLine the line number resulting in the write command.
62 * @returns The base name of the generated file (without extension).
63 */
64 QCString writeMermaidSource(const QCString &outDirArg, const QCString &fileName,
65 const QCString &content, ImageFormat format,
66 const QCString &srcFile, int srcLine);
67
68 /** Register a generated Mermaid image with the index.
69 * @param[in] baseName the name of the generated file (as returned by writeMermaidSource())
70 * @param[in] outDir the directory containing the resulting image.
71 * @param[in] format the image format that was generated.
72 * @param[in] toIndex add the file to the index lists for htmlhelp / qhc etc.
73 */
74 void generateMermaidOutput(const QCString &baseName, const QCString &outDir, ImageFormat format, bool toIndex);
75
82 using DiagramList = std::vector<MermaidDiagram>;
83
84 static QCString imageExtension(ImageFormat imageFormat);
86
87 private:
89
91 bool m_hasInlineDiagrams = false;
92};
93
94#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:252
OutputFormat
Mermaid output image formats.
Definition mermaid.h:44
bool m_hasInlineDiagrams
Definition mermaid.h:91
void generateMermaidOutput(const QCString &baseName, const QCString &outDir, ImageFormat format, bool toIndex)
Register a generated Mermaid image with the index.
Definition mermaid.cpp:117
bool hasInlineDiagrams() const
Definition mermaid.h:50
static QCString imageExtension(ImageFormat imageFormat)
Definition mermaid.cpp:43
static MermaidManager & instance()
Definition mermaid.cpp:33
DiagramList m_diagrams
Definition mermaid.h:90
void setHasInlineDiagrams()
Definition mermaid.cpp:245
static ImageFormat convertToImageFormat(OutputFormat outputFormat)
Definition mermaid.cpp:54
std::vector< MermaidDiagram > DiagramList
Definition mermaid.h:82
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:103
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:80
MermaidDiagram(ImageFormat fmt, MermaidDiagramInfo &&inf)
Definition mermaid.h:78