5 #include "create_docu.hpp"
9 DocuCreator::create_docu(Namespace* ns)
11 std::string fromfile = original_file != "" ? original_file : inputfile;
13 writer.openTag("documentation");
14 writer.openTag("namespace");
15 writer.writeAttribute("name", ns->name);
17 for(std::vector<AtomicType*>::iterator i = ns->types.begin();
18 i != ns->types.end(); ++i) {
19 AtomicType* type = *i;
20 Class* _class = dynamic_cast<Class*> (type);
22 create_class_docu(_class);
24 for(std::vector<Function*>::iterator i = ns->functions.begin();
25 i != ns->functions.end(); ++i) {
26 create_function_docu(0, *i);
29 writer.closeTag("namespace");
30 writer.closeTag("documentation");
34 DocuCreator::create_class_docu(Class* _class)
36 writer.openTag("class");
37 writer.writeAttribute("name", _class->name);
39 if(_class->docu_comment != "") {
40 writer.writeTag("documentation");
41 writer.write(_class->docu_comment);
44 for(std::vector<ClassMember*>::iterator i = _class->members.begin();
45 i != _class->members.end(); ++i) {
46 ClassMember* member = *i;
47 if(member->visibility != ClassMember::PUBLIC)
49 Function* function = dynamic_cast<Function*> (member);
52 if(function->type != Function::FUNCTION)
54 create_function_docu(_class, function);
57 writer.closeTag("class");
61 DocuCreator::create_function_docu(Class* _class, Function* function)
63 writer.openTag("function");
65 writer.writeAttribute("return_type",
66 get_type(function->return_type));
67 writer.writeAttribute("name", function->name);
69 if(function->docu_comment != "") {
70 writer.writeTag("documentation");
71 writer.write(function->docu_comment);
74 for(std::vector<Parameter>::iterator p = function->parameters.begin();
75 p != function->parameters.end(); ++p) {
76 if(p == function->parameters.begin()
77 && p->type.atomic_type == HSQUIRRELVMType::instance())
80 writer.writeTag("param");
81 writer.writeAttribute("type", get_type(p->type));
82 writer.writeAttribute("name", p->name);
85 writer.closeTag("function");
89 DocuCreator::get_type(const Type& type)
91 if(type.ref > 0 && type.atomic_type != StringType::instance())
92 throw std::runtime_error("References not handled yet");
94 throw std::runtime_error("Pointers not handled yet");
95 if(type.atomic_type == &BasicType::VOID) {
97 } else if(type.atomic_type == &BasicType::INT) {
99 } else if(type.atomic_type == &BasicType::FLOAT) {
101 } else if(type.atomic_type == &BasicType::BOOL) {
103 } else if(type.atomic_type == StringType::instance()) {
107 std::ostringstream msg;
108 msg << "Type '" << type.atomic_type->name << "' not supported yet.";
109 throw std::runtime_error(msg.str());