Implements modules documents

Editor can generate documents for modules in thier own xml files
This commit is contained in:
Geequlim 2016-12-16 19:12:22 +08:00 committed by Rémi Verschelde
parent 81a393a2b4
commit 886f646cba
4 changed files with 43 additions and 5 deletions

View file

@ -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;

View file

@ -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")

View file

@ -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) {

View file

@ -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);