ConsoleHelpGen.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #ifndef CRYINCLUDE_CRYSYSTEM_CONSOLEHELPGEN_H
  10. #define CRYINCLUDE_CRYSYSTEM_CONSOLEHELPGEN_H
  11. #if defined(WIN32) || defined(WIN64)
  12. #include "XConsole.h" // CXConsole, struct string_nocase_lt
  13. // extract consoel variable and command help
  14. // in some HTML pages and many small files that can be included in Confluence wiki
  15. // pages (so maintain the documentation only in one place)
  16. //
  17. // Possible improvements/Known issues:
  18. // - Nicer HTML layout (CSS?)
  19. // - Searching in the content of the cvars is tricky (main page doesn't have help content)
  20. // - %TODO% (was wiki image, should look good in confluence and HTML)
  21. // - many small files should be stored in some extra folder for clearity
  22. // - before generating the data the older directoy should be cleaned
  23. // - file should be generated in the user folder
  24. // - "wb" should be used instead of "w", to get the same result in unix
  25. class CConsoleHelpGen
  26. {
  27. public:
  28. CConsoleHelpGen(CXConsole& rParent)
  29. : m_rParent(rParent)
  30. , m_eWorkMode(eWM_None)
  31. {
  32. }
  33. void Work();
  34. private: // --------------------------------------------------------
  35. enum EWorkMode
  36. {
  37. eWM_None,
  38. eWM_HTML,
  39. eWM_Confluence
  40. };
  41. //
  42. void CreateMainPages();
  43. // to create one file for for each cvar/command in confluence style
  44. void CreateFileForEachEntry();
  45. // insert if the name starts with the with prefix
  46. void InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, const char* szPrefix) const;
  47. // insert if the name starts with the with prefix
  48. void InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, const char* szPrefix) const;
  49. // insert if the name does not start with any of the prefix in the map
  50. void InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const;
  51. // insert if the name does not start with any of the prefix in the map
  52. void InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const;
  53. // a single file for the entry is generate
  54. void CreateSingleEntryFile(const char* szName) const;
  55. void IncludeSingleEntry(FILE* f, const char* szName) const;
  56. static AZStd::string FixAnchorName(const char* szName);
  57. static AZStd::string GetCleanPrefix(const char* p);
  58. // split before "|" (to get the prefix itself)
  59. static AZStd::string SplitPrefixString_Part1(const char* p);
  60. // split string after "|" (to get the optional help)
  61. static const char* SplitPrefixString_Part2(const char* p);
  62. void StartPage(FILE* f, const char* szPageName, const char* szPageDescription) const;
  63. void EndPage(FILE* f) const;
  64. void StartH1(FILE* f, const char* szName) const;
  65. void EndH1(FILE* f) const;
  66. void StartH3(FILE* f, const char* szName) const;
  67. void EndH3(FILE* f) const;
  68. void StartCVar(FILE* f, const char* szName) const;
  69. void EndCVar(FILE* f) const;
  70. void SingleLinePrefix(FILE* f, const char* szPrefix, const char* szPrefixDesc, const char* szLink) const;
  71. void StartPrefix(FILE* f, const char* szPrefix, const char* szPrefixDesc, const char* szLink) const;
  72. void EndPrefix(FILE* f) const;
  73. void SingleLineEntry_InGlobal(FILE* f, const char* szName, const char* szLink) const;
  74. void SingleLineEntry_InGroup(FILE* f, const char* szName, const char* szLink) const;
  75. void Anchor(FILE* f, const char* szName) const;
  76. // to log some inital stats like date or application name
  77. void KeyValue(FILE* f, const char* szKey, const char* szValue) const;
  78. // prefix explanation and indention for following text
  79. void Explanation(FILE* f, const char* szText) const;
  80. void Separator(FILE* f) const;
  81. void LogVersion(FILE* f) const;
  82. // case senstive
  83. // Returns
  84. // 0 if not found
  85. const CConsoleCommand* FindConsoleCommand(const char* szName) const;
  86. // ----------------------------------------------
  87. //
  88. const char* GetFolderName() const;
  89. //
  90. const char* GetFileExtension() const;
  91. // ----------------------------------------------
  92. CXConsole& m_rParent;
  93. EWorkMode m_eWorkMode; // during Work() thise true:HTML and false:Confluence at some point
  94. };
  95. #endif // defined(WIN32) || defined(WIN64)
  96. #endif // CRYINCLUDE_CRYSYSTEM_CONSOLEHELPGEN_H