diff options
author | Geequlim <geequlim@gmail.com> | 2016-12-16 19:12:22 +0800 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-03-04 17:20:36 +0100 |
commit | 886f646cbacdbf0fe87cdda4ddb145dc72919194 (patch) | |
tree | d105e91828dfafa263c4ae4615f29689a132daad | |
parent | 81a393a2b445c78f4f1bfc21a9e8cc2784ca39c9 (diff) |
Implements modules documents
Editor can generate documents for modules in thier own xml files
-rw-r--r-- | main/main.cpp | 11 | ||||
-rw-r--r-- | tools/editor/SCsub | 29 | ||||
-rw-r--r-- | tools/editor/doc/doc_data.cpp | 7 | ||||
-rw-r--r-- | tools/editor/doc/doc_data.h | 1 |
4 files changed, 43 insertions, 5 deletions
diff --git a/main/main.cpp b/main/main.cpp index 9be77c31b6..fb7f2ebceb 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1063,6 +1063,7 @@ bool Main::start() { bool editor=false; String doc_tool; + List<String> removal_docs; bool doc_base=true; String game_path; String script; @@ -1093,6 +1094,8 @@ bool Main::start() { bool parsed_pair=true; if (args[i]=="-doctool") { doc_tool=args[i+1]; + for(int j=i+2; j<args.size();j++) + removal_docs.push_back(args[j]); } else if (args[i]=="-script" || args[i]=="-s") { script=args[i+1]; } else if (args[i]=="-level" || args[i]=="-l") { @@ -1141,6 +1144,14 @@ bool Main::start() { } + for(List<String>::Element* E= removal_docs.front(); E; E=E->next()) { + DocData rmdoc; + if (rmdoc.load(E->get()) == OK) { + print_line(String("Removing classes in ") + E->get()); + doc.remove_from(rmdoc); + } + } + doc.save(doc_tool); return false; diff --git a/tools/editor/SCsub b/tools/editor/SCsub index 76eb65748a..c9b2392eb2 100644 --- a/tools/editor/SCsub +++ b/tools/editor/SCsub @@ -3,6 +3,8 @@ Import('env') env.editor_sources = [] +import os + def make_certs_header(target, source, env): @@ -29,11 +31,21 @@ def make_certs_header(target, source, env): def make_doc_header(target, source, env): - src = source[0].srcnode().abspath dst = target[0].srcnode().abspath - f = open(src, "rb") g = open(dst, "wb") - buf = f.read() + buf = "" + docbegin = "" + docend = "" + for s in source: + src = s.srcnode().abspath + f = open(src, "rb") + content = f.read() + buf += content[content.find("<class"): content.rfind("</doc>")] + if len(docbegin) == 0: + docbegin = content[0: content.find("<class")] + if len(docend) == 0: + docend = content[content.rfind("</doc>"): len(buf)] + buf = docbegin + buf + docend decomp_size = len(buf) import zlib buf = zlib.compress(buf) @@ -146,8 +158,15 @@ if (env["tools"] == "yes"): f.close() # API documentation - env.Depends("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml") - env.Command("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml", make_doc_header) + docs = ["#doc/base/classes.xml"] + moduledir = os.path.join(os.getcwd(), "..", "..", "modules") + for m in os.listdir(moduledir): + curmodle = os.path.join(moduledir, m) + docfile = os.path.join(curmodle, "classes.xml") + if os.path.isdir(curmodle) and os.path.isfile(docfile): + docs.append(docfile) + env.Depends("#tools/editor/doc_data_compressed.h", docs) + env.Command("#tools/editor/doc_data_compressed.h", docs, make_doc_header) # Certificates env.Depends("#tools/editor/certs_compressed.h", "#thirdparty/certs/ca-certificates.crt") diff --git a/tools/editor/doc/doc_data.cpp b/tools/editor/doc/doc_data.cpp index e0a4750862..47b8edfa04 100644 --- a/tools/editor/doc/doc_data.cpp +++ b/tools/editor/doc/doc_data.cpp @@ -158,6 +158,13 @@ void DocData::merge_from(const DocData& p_data) { } +void DocData::remove_from(const DocData &p_data) { + for(Map<String,ClassDoc>::Element* E=p_data.class_list.front(); E; E=E->next()) { + if(class_list.has(E->key())) + class_list.erase(E->key()); + } +} + void DocData::generate(bool p_basic_types) { diff --git a/tools/editor/doc/doc_data.h b/tools/editor/doc/doc_data.h index fead1da510..7601013979 100644 --- a/tools/editor/doc/doc_data.h +++ b/tools/editor/doc/doc_data.h @@ -98,6 +98,7 @@ public: public: void merge_from(const DocData& p_data); + void remove_from(const DocData& p_data); void generate(bool p_basic_types=false); Error load(const String& p_path); Error save(const String& p_path); |