72 const QCString &srcFile,
int srcLine)
92 if (i != -1) baseName = baseName.
left(i);
96 QCString mmdName = baseName +
".mmd";
105 err_full(srcFile, srcLine,
"Could not open file {} for writing", mmdName);
120 if (!toIndex)
return;
125 imgName = imgName.
mid(i + 1);
134 if (diagrams.empty())
return;
148 mmdc(mmdc_), args(args_), ext(ext_), srcFile(srcFile_), srcLine(srcLine_) {}
155 std::vector<MermaidCmd> mermaidCmds;
157 for (
const auto &diagram : diagrams)
160 if (diagram.info.content.isEmpty())
continue;
164 QCString inputFile = diagram.info.baseName +
".mmd";
165 QCString outputFile = diagram.info.baseName +
"." + ext;
172 if (cachedContent == diagram.info.content)
180 args +=
"-q -i \"" + inputFile +
"\" ";
181 args +=
"-o \"" + outputFile +
"\" ";
183 if (!mermaidConfigFile.
isEmpty())
185 args +=
"-c \"" + mermaidConfigFile +
"\" ";
188 mermaidCmds.emplace_back(mmdc, args,ext, diagram.info.srcFile, diagram.info.srcLine);
191 std::size_t numThreads =
static_cast<std::size_t
>(
Config_getInt(DOT_NUM_THREADS));
193 size_t total=mermaidCmds.size();
194 msg(
"Generating {} Mermaid files using {} threads\n", total, numThreads);
198 std::vector< std::future<int> > results;
201 for (
const auto &cmd : mermaidCmds)
203 auto processFile = [&cmd]()
210 "Problems running Mermaid (mmdc). Verify that the command '{} {}' works from the command line. Exit code: {}.",
211 cmd.mmdc, cmd.args, exitCode);
215 results.emplace_back(threadPool.
queue(processFile));
219 for (
auto &f : results)
222 msg(
"Generating Mermaid file {}/{}\n", offset, total);
228 for (
const auto &cmd : mermaidCmds)
231 msg(
"Generating Mermaid file {}/{}\n", offset, total);
238 "Problems running Mermaid (mmdc). Verify that the command '{} {}' works from the command line. Exit code: {}.",
239 cmd.mmdc, cmd.args, exitCode);
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
static IndexList * indexList
Minimal replacement for QFileInfo.
void run()
Run mmdc tool for all collected diagrams.
OutputFormat
Mermaid output image formats.
void generateMermaidOutput(const QCString &baseName, const QCString &outDir, ImageFormat format, bool toIndex)
Register a generated Mermaid image with the index.
static QCString imageExtension(ImageFormat imageFormat)
static MermaidManager & instance()
static ImageFormat convertToImageFormat(OutputFormat outputFormat)
std::vector< MermaidDiagram > DiagramList
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.
This is an alternative implementation of QCString.
QCString & prepend(const char *s)
size_t length() const
Returns the length of the string, not counting the 0-terminator.
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
char & at(size_t i)
Returns a reference to the character at index i.
bool isEmpty() const
Returns TRUE iff the string is empty.
const std::string & str() const
QCString & setNum(short n)
int findRev(char c, int index=-1, bool cs=TRUE) const
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
QCString left(size_t len) const
Class managing a pool of worker threads.
auto queue(F &&f, Args &&... args) -> std::future< decltype(f(args...))>
Queue the callable function f for the threads to execute.
#define Config_getInt(name)
#define Config_getBool(name)
#define Config_getString(name)
static void runMermaid(const MermaidManager::DiagramList &diagrams)
static std::mutex g_mermaidMutex
static int g_mermaidIndex
#define err_full(file, line, fmt,...)
std::ofstream openOutputStream(const QCString &name, bool append=false)
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Portable versions of functions that are platform dependent.
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
QCString getDotImageExtension()
A bunch of utility functions.