1
2
3
4
5
6 #ifndef GENDOC_GENDOC_PROJECT_INCLUDED
7 #define GENDOC_GENDOC_PROJECT_INCLUDED
8 #include <gendoc/gendoc/File.hpp>
9 #include <gendoc/gendoc/Filter.hpp>
10 #include <gendoc/html/Grammar.hpp>
11 #include <gendoc/html/HtmlContentFilePathResolver.hpp>
12 #include <sngcpp/pp/File.hpp>
13 #include <sngcpp/ast/SourceFile.hpp>
14 #include <sngcpp/binder/TypeBinder.hpp>
15 #include <sngcpp/symbols/SymbolTable.hpp>
16 #include <sngxml/dom/Document.hpp>
17 #include <soulng/lexer/Lexer.hpp>
18 #include <soulng/rex/Context.hpp>
19
20 namespace gendoc {
21
22 class Import
23 {
24 public:
25 Import(const std::u32string& name_, const std::string& relativePath_);
26 const std::u32string& Name() const { return name; }
27 const std::string& RelativePath() const { return relativePath; }
28 private:
29 std::u32string name;
30 std::string relativePath;
31 };
32
33 class Project : public gendoc::html::HtmlContentFilePathResolver, public sngcpp::binder::SourceFileResolver
34 {
35 public:
36 Project(const std::string& docFilePath_);
37 void Process(bool verbose, bool rebuild, bool single);
38 void Clean(bool verbose, bool single);
39 void ReadChildren();
40 void RunChildren(bool verbose, bool rebuild, bool clean, bool single);
41 void RunChildrenWithFlags(bool verbose, bool rebuild, const std::string& flags);
42 void RunChildrenSingle(bool verbose, bool rebuild, bool clean, bool ast, bool content);
43 void GenerateAst(bool verbose, bool rebuild, bool readAst);
44 void GenerateContent(bool verbose, bool rebuild, bool endMessage, bool single);
45 void ReadName();
46 void ReadTop();
47 void ReadParentNameAndSiblings();
48 void ReadFilter();
49 void ReadIncludePath();
50 void ReadFilePaths(bool verbose);
51 void ReadImports();
52 void SetAstFilePath();
53 void SetContentXmlFilePath();
54 void SetHtmlFilePath();
55 bool BuildAst(bool verbose, bool rebuild);
56 void WriteAst(bool verbose);
57 void ReadAst(bool verbose);
58 void ImportAsts(bool verbose);
59 void BuildSymbolTable();
60 void GenerateContentXml(bool verbose, bool rebuild);
61 void WriteContentXml(bool verbose);
62 void ReadContentXml(bool verbose);
63 void MakeDirectories();
64 void GenerateStyleSheet();
65 void GenerateHtmlCodeFiles(bool verbose, bool rebuild);
66 void ReadGrammarXmlFiles(bool verbose);
67 void GenerateHtmlContent(bool verbose, bool rebuild);
68 void ReadDocumentationXml(bool verbose, bool& rebuild);
69 std::string ResolveContentFilePath(const std::u32string& currentProjectName, const std::u32string& projectName, const std::string& relativeContentDirPath,
70 const std::u32string& symbolId) override;
71 sngcpp::ast::SourceFileNode* GetSourceFile(const std::string& sourceFilePath) const override;
72 private:
73 bool childrenRead;
74 std::vector<std::string> children;
75 std::vector<std::u32string> childProjects;
76 std::vector<std::u32string> childNames;
77 std::vector<std::u32string> siblingProjects;
78 int thisProjectIndex;
79 std::u32string name;
80 std::u32string parentName;
81 std::u32string topLink;
82 soulng::rex::Context context;
83 std::string docFilePath;
84 std::string rootDir;
85 std::unique_ptr<sngxml::dom::Document> doc;
86 FilterList filters;
87 std::string projectRoot;
88 std::vector<File> filePaths;
89 std::string includePath;
90 std::string astFilePath;
91 std::unique_ptr<sngcpp::ast::Node> ast;
92 std::vector<std::std::unique_ptr<Import>>imports;
93 std::vector<std::string> importAstFilePaths;
94 std::vector<std::std::unique_ptr<sngcpp::ast::Node>>importAsts;
95 std::vector<std::std::unique_ptr<soulng::lexer::Lexer>>lexers;
96 sngcpp::symbols::SymbolTable symbolTable;
97 std::unique_ptr<sngxml::dom::Document> contentXml;
98 sngcpp::pp::ProjectHeaderFileSet headerFiles;
99 std::string htmlFilePath;
100 std::string htmlDir;
101 std::string contentDir;
102 std::string fileDir;
103 std::string styleDir;
104 std::string styleDirName;
105 std::string styleFileName;
106 std::vector<sngcpp::ast::SourceFileNode*> sourceFiles;
107 std::vector<std::std::vector<sngcpp::ast::SourceFileNode*>>importSourceFiles;
108 std::map<std::string, sngcpp::ast::SourceFileNode*> sourceFileMap;
109 std::unordered_map<std::u32string, std::std::unique_ptr<sngxml::dom::Element>>inlineCodeMap;
110 std::string contentXmlFilePath;
111 bool contentXmlUpToDate;
112 bool astGenerated;
113 bool upToDate;
114 std::map<std::u32string, Import*> importMap;
115 std::string documentationXmlFileName;
116 std::unique_ptr<sngxml::dom::Document> documentationXml;
117 std::string grammarsXmlFilePath;
118 std::unique_ptr<sngxml::dom::Document> grammarsXmlDoc;
119 std::vector<gendoc::html::Grammar> grammars;
120 };
121
122 }
123
124 #endif // GENDOC_GENDOC_PROJECT_INCLUDED