7 #include "create_docu.hpp"
11 DocuCreator::create_docu(Namespace* ns)
13 std::string fromfile = original_file != "" ? original_file : inputfile;
15 writer.openTag("documentation");
16 writer.openTag("namespace");
17 writer.writeAttribute("name", ns->name);
19 for(std::vector<AtomicType*>::iterator i = ns->types.begin();
20 i != ns->types.end(); ++i) {
21 AtomicType* type = *i;
22 Class* _class = dynamic_cast<Class*> (type);
24 create_class_docu(_class);
26 for(std::vector<Function*>::iterator i = ns->functions.begin();
27 i != ns->functions.end(); ++i) {
28 create_function_docu(0, *i);
31 writer.closeTag("namespace");
32 writer.closeTag("documentation");
36 DocuCreator::create_class_docu(Class* _class)
38 writer.openTag("class");
39 writer.writeAttribute("name", _class->name);
41 if(_class->docu_comment != "") {
42 writer.writeTag("documentation");
43 writer.write(_class->docu_comment);
46 for(std::vector<ClassMember*>::iterator i = _class->members.begin();
47 i != _class->members.end(); ++i) {
48 ClassMember* member = *i;
49 if(member->visibility != ClassMember::PUBLIC)
51 Function* function = dynamic_cast<Function*> (member);
54 if(function->type != Function::FUNCTION)
56 create_function_docu(_class, function);
59 writer.closeTag("class");
63 DocuCreator::create_function_docu(Class* _class, Function* function)
65 writer.openTag("function");
67 writer.writeAttribute("return_type",
68 get_type(function->return_type));
69 writer.writeAttribute("name", function->name);
71 if(function->docu_comment != "") {
72 writer.writeTag("documentation");
73 writer.write(function->docu_comment);
76 for(std::vector<Parameter>::iterator p = function->parameters.begin();
77 p != function->parameters.end(); ++p) {
78 if(p == function->parameters.begin()
79 && p->type.atomic_type == HSQUIRRELVMType::instance())
82 writer.writeTag("param");
83 writer.writeAttribute("type", get_type(p->type));
84 writer.writeAttribute("name", p->name);
87 writer.closeTag("function");
91 DocuCreator::get_type(const Type& type)
93 if(type.ref > 0 && type.atomic_type != StringType::instance())
94 throw std::runtime_error("References not handled yet");
96 throw std::runtime_error("Pointers not handled yet");
97 if(type.atomic_type == &BasicType::VOID) {
99 } else if(type.atomic_type == &BasicType::INT) {
101 } else if(type.atomic_type == &BasicType::FLOAT) {
103 } else if(type.atomic_type == &BasicType::BOOL) {
105 } else if(type.atomic_type == StringType::instance()) {
109 std::ostringstream msg;
110 msg << "Type '" << type.atomic_type->name << "' not supported yet.";
111 throw std::runtime_error(msg.str());