Doxygen XLinks
by
V: 2511R0
Website: doxygen
Loading...
Searching...
No Matches
dxlapp.cpp
1//==================================================================================================
2//==================================================================================================
3// This implementation-file is part of DoxygenXLinks - A doxygen post-processor that allows to
4// define smarter <b>Doxygen</b>-links.
5//
6// \emoji :copyright: 2025-2026 A-Worx GmbH, Germany.
7// Published under \ref mainpage_license "Boost Software License".
8//==================================================================================================
9#include "dxlapp.hpp"
10#include "dxl.hpp"
11#include "index.hpp"
12
13#include "ALib.Lang.H"
14#include "ALib.ALox.Impl.H"
15#include "ALib.Bootstrap.H"
16#include "ALib.Camp.Base.H"
17
18
19#include <iostream>
20#include <algorithm>
21
22using namespace alib;
23
24
25namespace dxl {
26
28: App{} {
29 flags += Flags::CreateReleaseLox
30 + Flags::UseReleaseLoggerForDebugLogging
31 + Flags::ALoxVerbosityExportAllAndWriteBackRelLogger;
32}
33
35 // call parent's implementation. This bulk-loads the resources into the camps.
36 App::onBsPrepareResources();
37
38 // now, we just add the resources that parent App did not define for us.
39
40 APP.GetResourcePool().BootstrapBulk( APP.ResourceCategory,
41#define EOS ,
42
43//------------------------------------ Things required by App -----------------------------------
44"AppName", "DoxygenXLinks",
45"AppInfo", "@HL-"
46 "{} V.{}.\n"
47 "(c) 2025-{} AWorx GmbH.\n"
48 " Published under MIT License (Open Source).\n"
49 "More information is found at: https://alib.dev/DoxygenXLinks.\n" // <-todo: what will be the URL?
50 "@HL-",
51
52"AppStart", A_CHAR("{} {} started."),
53"DryRunStart", A_CHAR("!!! Dry-run mode - HTML-files will not be written!!!\n"),
54//"DryRunEnd", A_CHAR(""),
55
56"HlpUsage" , A_CHAR("sample [format=\"FORMATSPEC\" [now]|[file FILENAME]"),
57"HlpCLIAppName", A_CHAR("DoxygenXLinks"),
58
59//todo Im App kann man noch keine Resourcen überschreiben. Nicht dass ich die hier überschreiben
60// will, aber grundsätzlich muss das notürlich gehen. Hatte ich eh noch vor..
61//"AppVersion", "V.{}.",
62//"DryRunStart", "{} dry-run mode:\n@>>",
63//"DryRunEnd", "@<<",
64
65//---------------------------------------------- Enums ---------------------------------------------
66"Kinds",
67 "^0," "dir" ",3,"
68 "^1," "file" ",4,"
69 "^2," "page" ",4,"
70 "^3," "group" ",5,"
71 "^4," "docanchor" ",4,"
72
73 "^5," "namespace" ",5,"
74 "^6," "struct" ",5,"
75 "^7," "class" ",4,"
76 "^8," "union" ",5,"
77 "^9," "concept" ",5,"
78"^10," "Module" ",3,"
79
80"^11," "define" ",5,"
81"^12," "typedef" ",1,"
82"^13," "variable" ",1,"
83"^14," "function" ",2,"
84"^15," "enumeration" ",5,"
85"^16," "enumvalue" ",5,"
86"^17," "generic_member" ",3,"
87
88"^18," "FILEPATH_COMPONENT" ",5,"
89"^19," "UNKNOWN" ",3,"
90"^20," "UNSPECIFIED" ",3,"
91"^21," "ROOT" ",2,"
92"^22," "UNRESOLVED" ",3" EOS
93
94//------------------------------------------- Expressions ------------------------------------------
95"TKINDS" , A_CHAR("Entity Kind" ) EOS
96"TNODE" , A_CHAR("Index Node" ) EOS
97
98// Constant identifiers
99"EID0" , A_CHAR( "Dir" " I 3" ),
100"EID1" , A_CHAR( "File" " I 3" ),
101"EID2" , A_CHAR( "Page" " I 4" ),
102"EID3" , A_CHAR( "Group" " I 1" ),
103"EID4" , A_CHAR( "DocAnchor" " I 1 1" ),
104"EID5" , A_CHAR( "NameSpace" " I 1 1" ),
105"EID6" , A_CHAR( "Struct" " I 4" ),
106"EID7" , A_CHAR( "Class" " I 1" ),
107"EID8" , A_CHAR( "Union" " I 1" ),
108"EID9" , A_CHAR( "ConCept" " I 1 1" ),
109"EID10" , A_CHAR( "Macro" " I 1" ),
110"EID11" , A_CHAR( "TypeDef" " I 1" ),
111"EID12" , A_CHAR( "Variable" " I 1" ),
112"EID13" , A_CHAR( "Function" " I 1" ),
113"EID14" , A_CHAR( "Enumeration" " I 1" ),
114"EID15" , A_CHAR( "EnumValue" " I 1 1" ),
115"EID16" , A_CHAR( "GenericMember" " I 1 1" ),
116"EID17" , A_CHAR( "Record" " I 1" ),
117"EID18" , A_CHAR( "UnSpecified" " I 1 1" ),
118
119// Function names
120"EID19" , A_CHAR( "LinkString" " I 1 1" ),
121"EID20" , A_CHAR( "Display" " I 1" ),
122"EID21" , A_CHAR( "Kind" " I 1" ),
123"EID22" , A_CHAR( "Target" " I 1" ),
124"EID23" , A_CHAR( "Name" " I 1" ),
125"EID24" , A_CHAR( "Path" " I 4" ),
126"EID25" , A_CHAR( "Parent" " I 1" ),
127"EID26" , A_CHAR( "IsGood" " I 1 1" ),
128"EID27" , A_CHAR( "IsResolved" " I 1 1" ),
129"EID28" , A_CHAR( "HasError" " I 1 1" ),
130"EID29" , A_CHAR( "HasWarning" " I 1 1" ),
131"EID30" , A_CHAR( "ErrorCode" " I 1 1" ),
132"EID31" , A_CHAR( "CountScopeHints" " I 1 1 1" ),
133"EID32" , A_CHAR( "ScopeHint" " I 1 1" ),
134"EID33" , A_CHAR( "CountScope" " I 1 1" ),
135"EID34" , A_CHAR( "Scope" " I 1" ),
136"EID35" , A_CHAR( "Identifier" " I 1" ),
137"EID36" , A_CHAR( "CountParaMS" " I 1 1 1 0" ),
138"EID37" , A_CHAR( "ParaMS" " I 1 1 0" ),
139"EID38" , A_CHAR( "CountTemplateParaMS" " I 1 1 1 1 0" ),
140"EID39" , A_CHAR( "TemplateParaMS" " I 1 1 1 0" ),
141"EID40" , A_CHAR( "CountTemplateSpecParaMS" " I 1 1 1 1 1 0" ),
142"EID41" , A_CHAR( "TemplateSpecParaMS" " I 1 1 1 1 0" ),
143"EID42" , A_CHAR( "LinkDisplay" " I 1 1" ),
144"EID43" , A_CHAR( "LinkTarget" " I 1 1" ),
145"EID44" , A_CHAR( "KindSpec" " I 1 1" ),
146"EID45" , A_CHAR( "Depth" " I 3" ),
147"EID46" , A_CHAR( "TagFilePath" " I 1 1 1" ),
148"EID47" , A_CHAR( "TagFileName" " I 1 1 1" ),
149"EID48" , A_CHAR( "TagFileLine" " I 1 1 1" ),
150"EID49" , A_CHAR( "HtmlFile" " I 4 1" ),
151"EID50" , A_CHAR( "HtmlAnchor" " I 4 1" ),
152"EID51" , A_CHAR( "CountSourceLocationS" " I 1 1 1 0" ),
153"EID52" , A_CHAR( "CountHtmlLocationS" " I 1 1 1 0" ),
154"EID53" , A_CHAR( "IsScannedHtmlFile" " I 1 1 1 1" ),
155"EID54" , A_CHAR( "IsIndirectSourceFile" " I 1 1 1 1" ),
156"EID55" , A_CHAR( "IsInherited" " I 1 1" ),
157"EID56" , A_CHAR( "IsIndirectTypeDefMember" " I 1 1 1 1 1" ),
158"EID57" , A_CHAR( "IsIndirectTypeDef" " I 1 1 1 1" ),
159
160//-------------------------------------------- Exceptions ------------------------------------------
161"E<", "Exceptions::",
162"E", "1,ErrorOpeningFile" ",ED1"
163 ",2,UnknownKind" ",ED2"
164 ",10,XMLSyntaxError" ",ED10"
165 ",11,NotATagStart" ",ED11"
166 ",12,UnexpectedXMLTag" ",ED12"
167 ",13,XMLEndTagNotInSameLine" ",ED13"
168 ",14,FileNotOnRootLevel" ",ED14"
169 ",15,DuplicateChildName" ",ED15"
170 ",16,DuplicateCompound" ",ED16"
171 ",17,UnexpectedXMLValue" ",ED17"
172EOS
173
174"ED1", "Error opening {}file {!Q}." EOS
175"ED2", "Unknown kind found @ {}:{} XML: {!Q} found." EOS
176"ED10", "XML Syntax error @ {}:{} XML: {!Q}" EOS
177"ED11", "Expected a start of a tag @ {}:{} XML: {!Q}" EOS
178"ED12", "Unexpected XML-tag @ {}:{} Expected: <{!Q}> Given: {!Q}" EOS
179"ED13", "XML end-tag not found in same line @ {}:{} Expected: \"</{}>\" Given: {!Q}" EOS
180"ED14", "File-Compound not on root level of XML file @ {}:{}" EOS
181"ED15", "Duplicate member name {!Q} in path {!Q}\n"
182 " First definition: @ {}:{}\n"
183 " Second definition: @ {2}:{}" EOS
184"ED16", "Duplicate compound {!Q}\n"
185 " First definition: @ {}:{}\n"
186 " Second definition: @ {1}:{}" EOS
187"ED17", "Unexpected value in XML tag @ {}:{} Expected: <{!Q}> Given: {!Q}" EOS
188
189
190//-------------------------------------- XL Error/Warning texts ------------------------------------
191"XL_ERR_0", "OK" EOS
192"XL_ERR_1", "Too many parents requested to be displayed" EOS
193"XL_ERR_2", "An anchor without a title was used without providing a user-defined display string.\n"
194 "DoxygenXLinks (like Doxygen itself) inserts the anchor name in this case.\n"
195 "To mitigate this warning, add \";1\" to the link or add a reasonable display string." EOS
196"XL_ERR_3", "A display tweak was given that is not applicable to the resolved target type" EOS
197"XL_ERR_5", "The search string is empty (apart from possible whitespaces)." EOS
198"XL_ERR_6", "No target identifier found." EOS
199"XL_ERR_7", "Too many scope-hints (words separated with spaces) were given." EOS
200"XL_ERR_8", "The number of nested scope (namespaces/compounds) is too huge to be processed by DoxygenXLinks (the maximum is 20)" EOS
201"XL_ERR_9", "The underlying type requested with '^' was not found." EOS
202"XL_ERR_10","Unknown kind type requested with '!', or missing space after kind. Allowed type kinds are:\n" // todo: the '!' is wrong
203 " 'd'=directory, 'f'=file, 'p'=Macro, 'n'=Namespace,'c'=Concept, 't'=Typedef 'r'=RECORD, 'c'=class, \n"
204 " 's'=struct, 'u'=union, 'e'=Enumeration 'a'=Enum element 'm'=Function, 'v'=Variable" EOS
205"XL_ERR_11","A local link (aka the identifier section starts with '.') must not have scope hints." EOS
206"XL_ERR_12","This error occurs with the command line option '--doxyfy'.\n"
207 "As explained in the user manual, equal local links cannot be restored back to\n"
208 "Doxygen's \\\\ref command if they occur in different HTML files. Please check each\n"
209 "location below and manually correct the link to target the right local entitiy." EOS
210"XL_ERR_13","This error occurs with the command line option '--doxyfy'.\n"
211 "It is issued when a local XLink is found in the source-copy to be restored, which has not\n"
212 "been found in the HTML files.\n"
213 "This usually indicates an erroneous setup of the documentation build-steps." EOS
214"XL_ERR_14","The local link was found in an HTML-file that is not found in the doxygen index\n"
215 "(tag-file). This happens, for example, if a local link is used in the short \n"
216 "description of a class and this class then appears in \"hierarchy.html\"." EOS
217
218
219//-------------------------------------------- Variables -------------------------------------------
220//------------------------------------------- Config files -----------------------------------------
221"CFGF_NAME_1" , ALIB_REL_DBG( "DoxygenXLinks.ini",
222 "DoxygenXLinks.ini" ),
223"CFGF_NAME_2" , ALIB_REL_DBG( "DoxygenXLinks.alib.ini",
224 "DoxygenXLinks.alib.ini" ),
225
226"CFGF_EXP_1" , "/",
227"CFGF_EXP_2" , "ALIB,ALOX",
228
229
230"CFGF_CMT_1",
231"@>'# '"
232"@HL="
233"DoxygenXLinks Configuration File\n"
234"(c) 2025-2026 AWorx GmbH. Published under MIT License (Open Source).\n"
235"@HL-\n"
236"Notes:\n\n@*>"
237"All configuration may also be set using environment variables or command-line parameters. "
238"In this case, such settings 'overrule' those of this INI-File. (While command-line "
239"arguments overrule environment variables.)@P\n"
240
241"Variable values can be substituted using ${VARIABLE_NAME}. This allows to add custom "
242"variables and assemble defined variables with the custom ones. For an example, see variable "
243"\"DL_LOGFILE_VERBOSITY\" below (section [DL], name \"LOGFILE_VERBOSITY\").@P\n"
244
245"Sections [ALIB] and [ALOX] are used by underlying libraries the DoxygenXLinks is build on. "
246"By default, these sections reside in (this) main INI-file. It is however possible to "
247"separate the two sections into a different file to reduce clutter. "
248"(Invoke 'DoxygenXLinks -h=config' for options on this).@P@P"
249"ALox is the logging system that the DoxygenXLinks uses to produce log output. For more information on how"
250"to leverage the variables exposed in these sections, refer to:@P"
251" http://alexworx.github.io/ALox-Logging-Library/group__GrpALoxConfigVars.html @P\n"
252
253"If this INI-file gets deleted (or partly deleted) all built-in default sections, variables, "
254"values and comments will be freshly written on the next invocation of DoxygenXLinks. "
255
256"@<*"
257"@HL=" EOS
258
259"CFGF_CMT_2",
260"@>'# '"
261"@HL="
262"DoxygenXLinks Configuration File for underlying libraries ALib and ALox\n"
263"(c) 2025-2026 AWorx GmbH. Published under MIT License (Open Source).\n"
264"@HL-\n"
265"Note:\n"
266"@>>"
267"This is a separated, secondary configuration file of the DoxygenXLinks software, containing "
268"mainly variables of the underlying logging system ALox.\n"
269"To leverage the variables exposed in this file, refer to:\n"
270" https://alib.dev/alib_alox_cfgvars.html\n"
271"By default, the name of the main configuration file is 'DoxygenXLinks.ini'.\n"
272"@<<"
273"@HL="
274EOS
275
276
277//--------------------------------------------------------------------------------------------------
278//----------------------------------------------- CLI ----------------------------------------------
279//--------------------------------------------------------------------------------------------------
280
281//------------------------------------------- CLI Commands -----------------------------------------
282"DLCmds<", "Commands::",
283"DLCmds",
284//enum ident minread Params
285"1," "clean" ",1" ",PD" EOS
286
287"THlpCmdSht_clean", A_CHAR("Reports the actual date/time"),
288"THlpCmdLng_clean", A_CHAR("Reports the actual date/time. May be omitted, as this is the\n"
289 "default if no command is given.") EOS
290
291
292
293//------------------------------------------- CLI Options ------------------------------------------
294"DLOptions<", "Options::",
295"DLOptions",
296//enum ident minread identChar in-arg-separ. args to consume ShortcutTo
297"" EOS
298
299
300//------------------------------------------ CLI Parameters ----------------------------------------
301"DLParams",
302
303//enum name minIdentLen identifier in-arg-sep delim args to consume isOptional
304// (if empty -> mandatory!)
305"1," "PD" ",1," "" "," "=" "," ",-1" ",1" EOS
306
307"DLParams<", "Parameters::",
308
309//-------------------------------------------- Exit Codes ------------------------------------------
310"DLExitCodes",
311//enum name assoc. cli exception
312"0," "OK" ","
313"20," "CantOpenDoxyfile" ","
314"21," "NoTagfileGeneratedByDoxyfile" ","
315"22," "OtherErrorInDoxyfile" ","
316"23," "TagFileNotFound" ","
317"24," "NoHTMLFilesFound" ","
318"25," "CantOpenHMLFile" ","
319"26," "CantWriteHMLFile" ","
320"27," "NoSourceFilesFound" ","
321"28," "CantOpenSrcFile" ","
322"29," "NoSourceCopiesFound" ","
323"30," "CantOpenReplSrcFile" ","
324"31," "CantWriteReplSrcFile" ","
325"32," "NoReplacementSourceFiles" EOS
326
327"DLExitCodes<", "ExitCodes::"
328
329,"TExit20", "Doxygen (INI-)file {!Q} not found or not accessible."
330,"TExit21", "Entry GENERATE_TAGFILE needs to be set in {!Q} to enable DoxygenXLinks."
331,"TExit22", "Error parsing the Doxygen file {!Q}. Details: {}"
332,"TExit23", "The tag-file {!Q} specified in the Doxygen (INI-)file {!Q} was not found."
333,"TExit24", "No Doxygen output files with extension {!Q} found in directory {!Q}"
334,"TExit25", "Cannot open HTML file {!Q} (maybe not accessible)."
335,"TExit26", "Cannot write HTML file {!Q} (Error code {})."
336,"TExit27", "Did not find any source file with the specifications given in doxyfile {!Q}."
337,"TExit28", "Cannot open source file {!Q} (maybe not accessible)."
338,"TExit29", "Did not find any copy of source files in folder {!Q} given with option --doxyfy."
339,"TExit30", "Cannot open replacement source {!Q} (maybe not accessible)."
340,"TExit31", "Cannot write replacement source file {!Q} (Error code {})."
341EOS
342
343//------------------------------------------ CLI Help Texts ----------------------------------------
344"HlpGeneral",
345"\nABOUT DoxygenXLinks\n"
346"@>>"
347"This is a command-line interface..."
348"\n@<<\n"
349
350EOS
351
352 // end of BootstrapBulk()
353 nullptr );
354
355 //---- replace some default values of ALOX variables ----
356 {
357 ResourcePool& pool = ALOX.GetResourcePool();
358 NCString& category= ALOX.ResourceCategory;
359 #if ALIB_DEBUG
360 # define errMsg "Error: Incompatible ALox resource string found. Update your code to current ALib version."
361 #endif
362
363 ALIB_ASSERT_ERROR( pool.Get(category, "Var2" ALIB_DBG(,true)).Equals("3|ALOX/%2/VERBOSITY_WITH_%1|ALOXV"), "DLCLI", errMsg )
364 pool.BootstrapAddOrReplace( category, "Var2", "3|ALOX/%2/VERBOSITY|ALOXV" );
365 pool.BootstrapAddOrReplace( category, "Var_D3", "${VERBOSITIES/DEFAULT}" );
366 }
367
368 #if ALIB_DEBUG
369 # undef errMsg
370 #endif
371}
373 // call parent's implementation. This bulk-loads the resources into the camps.
374 App::onBsPrepareConfig();
375
376// enumrecords::bootstrap::Bootstrap<dxl::Commands >();
377// enumrecords::bootstrap::Bootstrap<dxl::Parameters >();
378// enumrecords::bootstrap::Bootstrap<dxl::Options >();
381
382
383 //--------------------------------- BootstrapPhases::PrepareConfig -------------------------------
387
388 namespace erb= alib::enumrecords::bootstrap;
389 erb::Bootstrap<dxl::Exceptions>();
390// erb::Bootstrap<VerbosityPresets>( '|' );
391
392 #if ALIB_DEBUG
393
394 // todo: vielleicht sollte man für sowas ein extra DBGPreparations in alib::App machen?
395 // einfach damits aufgeräumt ist? Und der user, wenn er über die Reference doku geht
396 // und sich die States ansieht, dort den Hinweis bekommt? Und man könnte ja dort auch
397 // gleich beispielhaft die enums der app registrieren.
398 assert::RegisterPrintable(typeid(Target::Kinds), [](const std::any& any, std::string& s) {
399 s+= NString256(std::any_cast<Target::Kinds>(any));
400 });
401 #endif
402}
403
404
405
407 String infoFmtString= APP.GetResource("AppVersion");
408 String128 buffer;
410 Formatter::DEFAULT->Format( buffer, infoFmtString, alib::VERSION, alib::REVISION );
412
413 App::onBsSetNameVersionAndInfo();
414}
415
417 App::onBsCLIDefine();
418 cli.DefineExitCodes <enum dxl::ExitCodes >();
419// cli.DefineParameters<enum dxl::Parameters>();
420// cli.DefineCommands <enum dxl::Commands >();
421// cli.DefineOptions <enum dxl::Options >();
422}
423
424
426 if ( App::processCLICmd(cmd) )
427 return true;
428
429 if ( cmd == nullptr ) {
430 if (cli.ArgsLeft.size() == 0) {
431 ALIB_ERROR("DLX", "NIY: error output that no doxyfile given")
432 }
433 DoxyfilePath= cli.PopArg();
434 dxl= new DoxygenXLinks();
435 dxl->Run();
436 return true;
437 }
438
439 return false;
440}
441
442
444 App::onRunEnd();
445 if (dxl) {
446 dxl->TPool.WaitForAllIdle(10min ALIB_DBG(, 5s) );
447 dxl->TPool.Shutdown();
448 delete dxl;
449 dxl= nullptr;
450 }
451
452}
453
454
455} //namespace [dxl]
456
458//##################################################################################################
459// main()
460//##################################################################################################
461int main( int argc, const char** argv) { return dxl::DXLApp().Main(argc, argv); }
462#include "ALib.Lang.CIMethods.H"
#define A_CHAR(STR)
#define ALIB_ERROR(domain,...)
#define ALIB_LOCK_RECURSIVE_WITH(lock)
#define ALIB_DBG(...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_REL_DBG(releaseCode,...)
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE(TAppendable)
virtual int Main(int argc, const char **argv, const wchar_t **argvw=nullptr)
CommandLine cli
static threads::RecursiveLock DEFAULT_LOCK
static SPFormatter DEFAULT
virtual bool BootstrapAddOrReplace(const NString &category, const NString &name, const String &data)=0
virtual const String & Get(const NString &category, const NString &name, bool dbgAssert)=0
class DXLApp
Definition dxlapp.hpp:37
bool processCLICmd(alib::app::Command *cmd) override
Definition dxlapp.cpp:425
void onBsSetNameVersionAndInfo() override
Definition dxlapp.cpp:406
void onRunEnd() override
Waits for our thread-pool to become idle, shuts it down, and deletes it.
Definition dxlapp.cpp:443
void onBsPrepareConfig() override
Bootstraps enum records.
Definition dxlapp.cpp:372
void onBsCLIDefine() override
Defines #"alib_cliapp;CLI entities" specific to DoxygenXLinks.
Definition dxlapp.cpp:416
DXLApp()
Constructor.
Definition dxlapp.cpp:27
alib::String DoxyfilePath
The file path of the Doxyfile as given on the command line.
Definition dxlapp.hpp:56
void onBsPrepareResources() override
Bulk-loads DoxygenXLinks specific resource strings into module #"APP".
Definition dxlapp.cpp:34
Kinds
Enumerates the kinds of compounds found in a the Doxygen tagfile.
Definition target.hpp:28
void RegisterPrintable(std::type_index typeIndex, AnyConversionFunc func)
void Bootstrap(camp::Camp &camp, const NString &name, character innerDelim=',', character outerDelim=',')
TMonoAllocator< lang::HeapAllocator > GLOBAL_ALLOCATOR
resources::ResourcePool ResourcePool
strings::TCString< nchar > NCString
lox::ALoxCamp ALOX
int VERSION
strings::TString< character > String
LocalString< 128 > String128
NLocalString< 256 > NString256
app::AppCamp APP
unsigned char REVISION
todox
Definition doxyfile.cpp:20
Exceptions
Definition dxl.hpp:108
ExitCodes
Definition dxl.hpp:87