mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
Fix various issues with API documentation generator
This commit is contained in:
parent
ee024f3dc5
commit
68cf8cf44f
@ -760,13 +760,13 @@ STRIP_CODE_COMMENTS = YES
|
|||||||
# then for each documented function all documented
|
# then for each documented function all documented
|
||||||
# functions referencing it will be listed.
|
# functions referencing it will be listed.
|
||||||
|
|
||||||
REFERENCED_BY_RELATION = YES
|
REFERENCED_BY_RELATION = NO
|
||||||
|
|
||||||
# If the REFERENCES_RELATION tag is set to YES
|
# If the REFERENCES_RELATION tag is set to YES
|
||||||
# then for each documented function all documented entities
|
# then for each documented function all documented entities
|
||||||
# called/used by that function will be listed.
|
# called/used by that function will be listed.
|
||||||
|
|
||||||
REFERENCES_RELATION = YES
|
REFERENCES_RELATION = NO
|
||||||
|
|
||||||
# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
|
# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
|
||||||
# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
|
# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
|
||||||
|
@ -30,6 +30,7 @@ def comment(code):
|
|||||||
if empty_line:
|
if empty_line:
|
||||||
# New paragraph.
|
# New paragraph.
|
||||||
comment += '\n\n'
|
comment += '\n\n'
|
||||||
|
empty_line = False
|
||||||
elif comment:
|
elif comment:
|
||||||
comment += '\n'
|
comment += '\n'
|
||||||
comment += '/// ' + line
|
comment += '/// ' + line
|
||||||
@ -56,15 +57,29 @@ def block_comment(code):
|
|||||||
|
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
strline = line.lstrip('/ \t')
|
strline = line.lstrip('/ \t')
|
||||||
if reading_desc:
|
|
||||||
newlines.append('/// ' + line[min(indent, len(line) - len(strline)):])
|
if ':' in strline:
|
||||||
else:
|
pre, post = strline.split(':', 1)
|
||||||
# A "Description:" text starts the description.
|
pre = pre.rstrip()
|
||||||
if strline.startswith("Description"):
|
if pre == "Description":
|
||||||
strline = strline[11:].lstrip(': \t')
|
strline = post.lstrip()
|
||||||
indent = len(line) - len(strline)
|
elif pre in ("Class", "Access", "Function", "Created by", "Enum"):
|
||||||
reading_desc = True
|
continue
|
||||||
newlines.append('/// ' + strline)
|
|
||||||
|
if strline or len(newlines) > 0:
|
||||||
|
newlines.append('/// ' + strline)
|
||||||
|
|
||||||
|
#if reading_desc:
|
||||||
|
# newlines.append('/// ' + line[min(indent, len(line) - len(strline)):])
|
||||||
|
#else:
|
||||||
|
# # A "Description:" text starts the description.
|
||||||
|
# if strline.startswith("Description"):
|
||||||
|
# strline = strline[11:].lstrip(': \t')
|
||||||
|
# indent = len(line) - len(strline)
|
||||||
|
# reading_desc = True
|
||||||
|
# newlines.append('/// ' + strline)
|
||||||
|
# else:
|
||||||
|
# print line
|
||||||
|
|
||||||
newcode = '\n'.join(newlines)
|
newcode = '\n'.join(newlines)
|
||||||
if len(newcode) > 0:
|
if len(newcode) > 0:
|
||||||
@ -73,6 +88,9 @@ def block_comment(code):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
def translateFunctionName(name):
|
def translateFunctionName(name):
|
||||||
|
if name.startswith("__"):
|
||||||
|
return name
|
||||||
|
|
||||||
new = ""
|
new = ""
|
||||||
for i in name.split("_"):
|
for i in name.split("_"):
|
||||||
if new == "":
|
if new == "":
|
||||||
@ -85,32 +103,58 @@ def translateFunctionName(name):
|
|||||||
new += i[0].upper() + i[1:]
|
new += i[0].upper() + i[1:]
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def translated_type_name(type):
|
def translateTypeName(name, mangle=True):
|
||||||
|
# Equivalent to C++ classNameFromCppName
|
||||||
|
class_name = ""
|
||||||
|
bad_chars = "!@#$%^&*()<>,.-=+~{}? "
|
||||||
|
next_cap = False
|
||||||
|
first_char = mangle
|
||||||
|
|
||||||
|
for chr in name:
|
||||||
|
if (chr == '_' or chr == ' ') and mangle:
|
||||||
|
next_cap = True
|
||||||
|
elif chr in bad_chars:
|
||||||
|
if not mangle:
|
||||||
|
class_name += '_'
|
||||||
|
elif next_cap or first_char:
|
||||||
|
class_name += chr.upper()
|
||||||
|
next_cap = False
|
||||||
|
first_char = False
|
||||||
|
else:
|
||||||
|
class_name += chr
|
||||||
|
|
||||||
|
return class_name
|
||||||
|
|
||||||
|
def translated_type_name(type, scoped=True):
|
||||||
|
while interrogate_type_is_wrapped(type):
|
||||||
|
if interrogate_type_is_const(type):
|
||||||
|
return 'const ' + translated_type_name(interrogate_type_wrapped_type(type))
|
||||||
|
else:
|
||||||
|
type = interrogate_type_wrapped_type(type)
|
||||||
|
|
||||||
|
typename = interrogate_type_name(type)
|
||||||
|
if typename in ("PyObject", "_object"):
|
||||||
|
return "object"
|
||||||
|
|
||||||
if interrogate_type_is_atomic(type):
|
if interrogate_type_is_atomic(type):
|
||||||
token = interrogate_type_atomic_token(type)
|
token = interrogate_type_atomic_token(type)
|
||||||
if token == 7:
|
if token == 7:
|
||||||
return 'str'
|
return 'str'
|
||||||
|
else:
|
||||||
|
return typename
|
||||||
|
|
||||||
typename = interrogate_type_name(type)
|
typename = translateTypeName(typename)
|
||||||
typename = typename.replace("< ", "").replace(" >", "")
|
|
||||||
return typename
|
|
||||||
|
|
||||||
def translateTypeSpec(name):
|
if scoped and interrogate_type_is_nested(type):
|
||||||
name = name.strip("* ")
|
return translated_type_name(interrogate_type_outer_class(type)) + '::' + typename
|
||||||
name = name.replace("BitMask< unsigned int, 32 >", "BitMask32")
|
else:
|
||||||
name = name.replace("atomic ", "")
|
return typename
|
||||||
name = name.replace("< ", "").replace(" >", "")
|
|
||||||
if name == '_object':
|
|
||||||
name = 'object'
|
|
||||||
elif name == '_typeobject':
|
|
||||||
name = 'type'
|
|
||||||
return name
|
|
||||||
|
|
||||||
def processElement(handle, element):
|
def processElement(handle, element):
|
||||||
if interrogate_element_has_comment(element):
|
if interrogate_element_has_comment(element):
|
||||||
print >>handle, comment(interrogate_element_comment(element))
|
print >>handle, comment(interrogate_element_comment(element))
|
||||||
|
|
||||||
print >>handle, translateTypeSpec(translated_type_name(interrogate_element_type(element))),
|
print >>handle, translated_type_name(interrogate_element_type(element)),
|
||||||
print >>handle, interrogate_element_name(element) + ';'
|
print >>handle, interrogate_element_name(element) + ';'
|
||||||
|
|
||||||
def processFunction(handle, function, isConstructor = False):
|
def processFunction(handle, function, isConstructor = False):
|
||||||
@ -120,11 +164,12 @@ def processFunction(handle, function, isConstructor = False):
|
|||||||
print >>handle, block_comment(interrogate_wrapper_comment(wrapper))
|
print >>handle, block_comment(interrogate_wrapper_comment(wrapper))
|
||||||
|
|
||||||
if not isConstructor:
|
if not isConstructor:
|
||||||
if not interrogate_wrapper_number_of_parameters(wrapper) > 0 or not interrogate_wrapper_parameter_is_this(wrapper, 0):
|
if interrogate_function_is_method(function):
|
||||||
print >>handle, "static",
|
if not interrogate_wrapper_number_of_parameters(wrapper) > 0 or not interrogate_wrapper_parameter_is_this(wrapper, 0):
|
||||||
|
print >>handle, "static",
|
||||||
|
|
||||||
if interrogate_wrapper_has_return_value(wrapper):
|
if interrogate_wrapper_has_return_value(wrapper):
|
||||||
print >>handle, translateTypeSpec(translated_type_name(interrogate_wrapper_return_type(wrapper))),
|
print >>handle, translated_type_name(interrogate_wrapper_return_type(wrapper)),
|
||||||
else:
|
else:
|
||||||
pass#print >>handle, "void",
|
pass#print >>handle, "void",
|
||||||
|
|
||||||
@ -137,7 +182,7 @@ def processFunction(handle, function, isConstructor = False):
|
|||||||
if not interrogate_wrapper_parameter_is_this(wrapper, i_param):
|
if not interrogate_wrapper_parameter_is_this(wrapper, i_param):
|
||||||
if not first:
|
if not first:
|
||||||
print >>handle, ",",
|
print >>handle, ",",
|
||||||
print >>handle, translateTypeSpec(translated_type_name(interrogate_wrapper_parameter_type(wrapper, i_param))),
|
print >>handle, translated_type_name(interrogate_wrapper_parameter_type(wrapper, i_param)),
|
||||||
if interrogate_wrapper_parameter_has_name(wrapper, i_param):
|
if interrogate_wrapper_parameter_has_name(wrapper, i_param):
|
||||||
print >>handle, interrogate_wrapper_parameter_name(wrapper, i_param),
|
print >>handle, interrogate_wrapper_parameter_name(wrapper, i_param),
|
||||||
first = False
|
first = False
|
||||||
@ -145,7 +190,7 @@ def processFunction(handle, function, isConstructor = False):
|
|||||||
print >>handle, ");"
|
print >>handle, ");"
|
||||||
|
|
||||||
def processType(handle, type):
|
def processType(handle, type):
|
||||||
typename = translated_type_name(type)
|
typename = translated_type_name(type, scoped=False)
|
||||||
derivations = [ translated_type_name(interrogate_type_get_derivation(type, n)) for n in range(interrogate_type_number_of_derivations(type)) ]
|
derivations = [ translated_type_name(interrogate_type_get_derivation(type, n)) for n in range(interrogate_type_number_of_derivations(type)) ]
|
||||||
|
|
||||||
if interrogate_type_has_comment(type):
|
if interrogate_type_has_comment(type):
|
||||||
@ -157,7 +202,7 @@ def processType(handle, type):
|
|||||||
docstring = comment(interrogate_type_enum_value_comment(type, i_value))
|
docstring = comment(interrogate_type_enum_value_comment(type, i_value))
|
||||||
if docstring:
|
if docstring:
|
||||||
print >>handle, docstring
|
print >>handle, docstring
|
||||||
print >>handle, translateFunctionName(interrogate_type_enum_value_name(type, i_value)), "=", interrogate_type_enum_value(type, i_value), ","
|
print >>handle, interrogate_type_enum_value_name(type, i_value), "=", interrogate_type_enum_value(type, i_value), ","
|
||||||
else:
|
else:
|
||||||
if interrogate_type_is_struct(type):
|
if interrogate_type_is_struct(type):
|
||||||
classtype = "struct"
|
classtype = "struct"
|
||||||
@ -192,38 +237,54 @@ def processType(handle, type):
|
|||||||
|
|
||||||
print >>handle, "};"
|
print >>handle, "};"
|
||||||
|
|
||||||
|
def processModule(handle, package):
|
||||||
|
print >>handle, "namespace %s {" % package
|
||||||
|
|
||||||
|
if package != "core":
|
||||||
|
print >>handle, "using namespace core;"
|
||||||
|
|
||||||
|
for i_type in xrange(interrogate_number_of_global_types()):
|
||||||
|
type = interrogate_get_global_type(i_type)
|
||||||
|
|
||||||
|
if interrogate_type_has_module_name(type):
|
||||||
|
module_name = interrogate_type_module_name(type)
|
||||||
|
if "panda3d." + package == module_name:
|
||||||
|
processType(handle, type)
|
||||||
|
else:
|
||||||
|
print "Type %s has no module name" % typename
|
||||||
|
|
||||||
|
for i_func in xrange(interrogate_number_of_global_functions()):
|
||||||
|
func = interrogate_get_global_function(i_func)
|
||||||
|
|
||||||
|
if interrogate_function_has_module_name(func):
|
||||||
|
module_name = interrogate_function_module_name(func)
|
||||||
|
if "panda3d." + package == module_name:
|
||||||
|
processFunction(handle, func)
|
||||||
|
else:
|
||||||
|
print "Type %s has no module name" % typename
|
||||||
|
|
||||||
|
print >>handle, "}"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
handle = open("pandadoc.hpp", "w")
|
handle = open("pandadoc.hpp", "w")
|
||||||
|
|
||||||
print >>handle, comment("Panda3D modules that are implemented in C++.")
|
print >>handle, comment("Panda3D modules that are implemented in C++.")
|
||||||
print >>handle, "namespace panda3d {}"
|
print >>handle, "namespace panda3d {"
|
||||||
|
|
||||||
# Determine the path to the interrogatedb files
|
# Determine the path to the interrogatedb files
|
||||||
interrogate_add_search_directory(os.path.join(os.path.dirname(pandac.__file__), "..", "..", "etc"))
|
interrogate_add_search_directory(os.path.join(os.path.dirname(pandac.__file__), "..", "..", "etc"))
|
||||||
interrogate_add_search_directory(os.path.join(os.path.dirname(pandac.__file__), "input"))
|
interrogate_add_search_directory(os.path.join(os.path.dirname(pandac.__file__), "input"))
|
||||||
|
|
||||||
import panda3d.core
|
import panda3d.core
|
||||||
|
processModule(handle, "core")
|
||||||
|
|
||||||
for lib in os.listdir(os.path.dirname(panda3d.__file__)):
|
for lib in os.listdir(os.path.dirname(panda3d.__file__)):
|
||||||
if lib.endswith(('.pyd', '.so')) and not lib.startswith('core.'):
|
if lib.endswith(('.pyd', '.so')) and not lib.startswith('core.'):
|
||||||
__import__('panda3d.' + os.path.splitext(lib)[0])
|
module_name = os.path.splitext(lib)[0]
|
||||||
|
__import__("panda3d." + module_name)
|
||||||
|
processModule(handle, module_name)
|
||||||
|
|
||||||
lastpkg = None
|
|
||||||
for i_type in xrange(interrogate_number_of_global_types()):
|
|
||||||
type = interrogate_get_global_type(i_type)
|
|
||||||
|
|
||||||
if interrogate_type_has_module_name(type):
|
print >>handle, "}"
|
||||||
package = interrogate_type_module_name(type)
|
|
||||||
if lastpkg != package:
|
|
||||||
if lastpkg is not None:
|
|
||||||
print >>handle, "}"
|
|
||||||
print >>handle, "namespace %s {" % package
|
|
||||||
lastpkg = package
|
|
||||||
|
|
||||||
processType(handle, type)
|
|
||||||
else:
|
|
||||||
print "Type %s has no module name" % typename
|
|
||||||
|
|
||||||
if lastpkg is not None:
|
|
||||||
print >>handle, "}"
|
|
||||||
handle.close()
|
handle.close()
|
||||||
|
@ -1651,7 +1651,7 @@ type_decl:
|
|||||||
}
|
}
|
||||||
| anonymous_enum
|
| anonymous_enum
|
||||||
{
|
{
|
||||||
$$ = CPPType::new_type($1);
|
$$ = new CPPTypeDeclaration(CPPType::new_type($1));
|
||||||
}
|
}
|
||||||
| named_enum
|
| named_enum
|
||||||
{
|
{
|
||||||
|
@ -200,6 +200,7 @@ define_extension_type(CPPExtensionType *type) {
|
|||||||
|
|
||||||
case CPPExtensionType::T_union:
|
case CPPExtensionType::T_union:
|
||||||
_unions[name] = type;
|
_unions[name] = type;
|
||||||
|
break;
|
||||||
|
|
||||||
case CPPExtensionType::T_enum:
|
case CPPExtensionType::T_enum:
|
||||||
_enums[name] = type;
|
_enums[name] = type;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NonlinearImager::Constructor
|
// Function: NonlinearImager::Constructor
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
NonlinearImager::
|
NonlinearImager::
|
||||||
NonlinearImager() {
|
NonlinearImager() {
|
||||||
@ -38,7 +38,7 @@ NonlinearImager() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NonlinearImager::Destructor
|
// Function: NonlinearImager::Destructor
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
NonlinearImager::
|
NonlinearImager::
|
||||||
~NonlinearImager() {
|
~NonlinearImager() {
|
||||||
@ -54,7 +54,7 @@ NonlinearImager::
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NonlinearImager::add_screen
|
// Function: NonlinearImager::add_screen
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// This version of this method is deprecated and will
|
// Description: This version of this method is deprecated and will
|
||||||
// soon be removed. Use the version that takes two
|
// soon be removed. Use the version that takes two
|
||||||
// parameters instead.
|
// parameters instead.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
// with this source code in a file named "LICENSE."
|
// with this source code in a file named "LICENSE."
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
INLINE void OdeRayGeom::
|
INLINE void OdeRayGeom::
|
||||||
set_length(dReal length) {
|
set_length(dReal length) {
|
||||||
dGeomRaySetLength(_id, length);
|
dGeomRaySetLength(_id, length);
|
||||||
|
@ -62,6 +62,7 @@ PUBLISHED:
|
|||||||
// INLINE void get_buffer(unsigned char** buf, int* buf_len) const;
|
// INLINE void get_buffer(unsigned char** buf, int* buf_len) const;
|
||||||
// INLINE void set_buffer(unsigned char* buf);
|
// INLINE void set_buffer(unsigned char* buf);
|
||||||
// INLINE void update();
|
// INLINE void update();
|
||||||
|
|
||||||
virtual void write(ostream &out = cout, unsigned int indent=0) const;
|
virtual void write(ostream &out = cout, unsigned int indent=0) const;
|
||||||
void write_faces(ostream &out) const;
|
void write_faces(ostream &out) const;
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ public:
|
|||||||
const int* indices, int index_count, \
|
const int* indices, int index_count, \
|
||||||
const int* normals);
|
const int* normals);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INLINE void preprocess();
|
INLINE void preprocess();
|
||||||
|
|
||||||
INLINE dTriMeshDataID get_id() const;
|
INLINE dTriMeshDataID get_id() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user