mirror of https://github.com/CGAL/cgal
* tex2doxy now automatically creates required doxygen and html
documentation * more matches between tex and doxy
This commit is contained in:
parent
ca93dfa79c
commit
58944630a6
|
|
@ -27,10 +27,6 @@ class Logger
|
||||||
log( 4, "!! Error: " + msg )
|
log( 4, "!! Error: " + msg )
|
||||||
end
|
end
|
||||||
|
|
||||||
def fatal( msg )
|
|
||||||
puts "!!! Fatal: " + msg
|
|
||||||
end
|
|
||||||
|
|
||||||
def log( l, msg )
|
def log( l, msg )
|
||||||
if l >= @level then
|
if l >= @level then
|
||||||
puts msg
|
puts msg
|
||||||
|
|
@ -43,19 +39,54 @@ class Logger
|
||||||
end
|
end
|
||||||
|
|
||||||
def internal_test
|
def internal_test
|
||||||
s=normalize_function_declaration( "template<class XX, typename YY=bla<blubb> >void bla(XX a, XX b, YY c)" )
|
s=normalize_declaration( "template<class XX, typename YY=bla<blubb> >void bla(XX a, XX b, YY c)", "function" )
|
||||||
fail unless s=="void bla($0,$0,$1)"
|
fail s unless s=="void bla($0,$0,$1)"
|
||||||
s=normalize_function_declaration( "template<class XX, typename YY=bla<blubb> > void bla(XX a, XX b, xYYz c)" )
|
s=normalize_declaration( "template<class XX, typename YY=bla<blubb> > void bla(XX a, XX b, xYYz c)", "function" )
|
||||||
fail unless s=="void bla($0,$0,xYYz)"
|
fail s unless s=="void bla($0,$0,xYYz)"
|
||||||
|
|
||||||
s=normalize_function_declaration( "template< class ForwardIterator1, class ForwardIterator2, class Callback > void box_intersection_all_pairs_d( ForwardIterator1 begin1, ForwardIterator1 end1, ForwardIterator2 begin2, ForwardIterator2 end2, Callback callback, Box_intersection_d::Topology topology = Box_intersection_d<bla<blubb>::blubber>::CLOSED);" )
|
s=normalize_declaration( "template< class ForwardIterator1, class ForwardIterator2, class Callback > void box_intersection_all_pairs_d_with_ForwardIterator1_in_its_name( ForwardIterator1 begin1, ForwardIterator1 end1, ForwardIterator2 begin2, ForwardIterator2 end2, Callback callback, Box_intersection_d::Topology topology = Box_intersection_d<bla<blubb>::blubber>::CLOSED);", "function" )
|
||||||
fail unless s=="void box_intersection_all_pairs_d($0,$0,$1,$1,$2,Box_intersection_d::Topology);"
|
fail unless s=="void box_intersection_all_pairs_d_with_ForwardIterator1_in_its_name($0,$0,$1,$1,$2,Box_intersection_d::Topology);"
|
||||||
|
s=normalize_declaration( "void foo( int bla[2][4] );", "function" )
|
||||||
|
fail unless s=="void foo(int[][]);"
|
||||||
|
s=normalize_declaration( "typedef std::size_t ID;", "typedef" )
|
||||||
|
fail unless s=="ID"
|
||||||
|
s=normalize_declaration( "typedef X<Y>ID;", "typedef" )
|
||||||
|
fail unless s=="ID"
|
||||||
|
s=normalize_declaration( "typedef X<Y> ID;", "typedef" )
|
||||||
|
fail unless s=="ID"
|
||||||
|
s="Box_d<NT,int D,Traits>"
|
||||||
|
fail unless enumerate_template_parameters( s )==['NT', 'int D', 'Traits']
|
||||||
|
end
|
||||||
|
|
||||||
|
def join( array, separator )
|
||||||
|
return nil if array.length == 0
|
||||||
|
retval = array[0].class.new
|
||||||
|
first = true
|
||||||
|
array.each do |x|
|
||||||
|
if first then
|
||||||
|
first = false
|
||||||
|
else
|
||||||
|
retval << separator
|
||||||
|
end
|
||||||
|
retval << x
|
||||||
|
end
|
||||||
|
return retval
|
||||||
|
end
|
||||||
|
|
||||||
|
def normalize_declaration_generic( decl )
|
||||||
|
decl.gsub!( /\bfriend\b/, '' );
|
||||||
|
decl.gsub!( /\bvirtual\b/, '' );
|
||||||
|
decl.gsub!( /\s+/, ' ' );
|
||||||
|
decl.gsub!( /(\w) ([&*()=:;,<>])/, '\1\2' );
|
||||||
|
decl.gsub!( /([()=:;,<>]) (\w)/, '\1\2' );
|
||||||
|
decl.gsub!( /([()=:;,<>]) ([&();,])/, '\1\2' );
|
||||||
|
decl.gsub!( /([();,]) ([()=:;,<>])/, '\1\2' );
|
||||||
|
return decl.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
# input: "template<class XX>void bla(XX t)"
|
# input: "template<class XX>void bla(XX t)"
|
||||||
# result: void bla($1 t)
|
# result: void bla($1 t)
|
||||||
def normalize_template_parameters( decl )
|
def normalize_template_parameters( decl )
|
||||||
typemap=Hash.new
|
|
||||||
if decl =~ /^template\s*/ then
|
if decl =~ /^template\s*/ then
|
||||||
decl=$'
|
decl=$'
|
||||||
outer, inner, rest = split_nesting_levels( '<', '>', decl )
|
outer, inner, rest = split_nesting_levels( '<', '>', decl )
|
||||||
|
|
@ -63,33 +94,32 @@ def normalize_template_parameters( decl )
|
||||||
decl=rest.sub( /^\s*>/, "" )
|
decl=rest.sub( /^\s*>/, "" )
|
||||||
counter = 0
|
counter = 0
|
||||||
protected_split( '<', '>', ',', inner ).each do |x|
|
protected_split( '<', '>', ',', inner ).each do |x|
|
||||||
x=x.gsub( /(class|typename)/, "" )
|
x.gsub!( /(class|typename)/, "" )
|
||||||
x = x.gsub( /=.*$/, "" ).strip
|
x = x.gsub( /=.*$/, "" ).strip
|
||||||
$log.debug "typemap[#{x}]=$#{counter}"
|
decl.gsub!( /\b#{x}\b/, "$#{counter}" )
|
||||||
typemap[x]="$#{counter}"
|
|
||||||
counter+=1
|
counter+=1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return decl, typemap
|
return decl
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize_declaration( decl )
|
def normalize_declaration( decl, kind )
|
||||||
decl = decl.gsub( /\s+/, ' ' );
|
decl = normalize_declaration_generic( decl )
|
||||||
decl = decl.gsub( /(\w) ([&()=:;,<>])/, '\1\2' );
|
case kind
|
||||||
decl = decl.gsub( /([()=:;,<>]) (\w)/, '\1\2' );
|
when /function/
|
||||||
decl = decl.gsub( /([()=:;,<>]) ([&();,])/, '\1\2' );
|
decl = normalize_template_parameters( decl )
|
||||||
decl = decl.gsub( /([();,]) ([()=:;,<>])/, '\1\2' );
|
if decl =~ /^([^(]+[(])/ then
|
||||||
return decl.strip
|
decl=$1+remove_argnames($')
|
||||||
end
|
end
|
||||||
|
when /typedef/
|
||||||
|
if decl =~ /([^ ;<>]+)(\s*)[;]?$/ then
|
||||||
def normalize_function_declaration( decl )
|
decl = $1
|
||||||
decl = normalize_declaration( decl )
|
|
||||||
decl,typemap = normalize_template_parameters( decl )
|
|
||||||
if decl =~ /([^(]+[(])/ then
|
|
||||||
decl=$1+remove_argnames($',typemap)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
decl = decl.gsub( /\btypename\b/, '' );
|
||||||
|
decl = normalize_declaration_generic( decl )
|
||||||
|
return decl
|
||||||
|
end
|
||||||
|
|
||||||
# input: s="xxxx<<dskd>dsad>dssd<x>"
|
# input: s="xxxx<<dskd>dsad>dssd<x>"
|
||||||
# returns: outer="xxxx<>dssd<>" inner="<dskd>dsad",x
|
# returns: outer="xxxx<>dssd<>" inner="<dskd>dsad",x
|
||||||
|
|
@ -126,7 +156,7 @@ end
|
||||||
# part: h
|
# part: h
|
||||||
# part: y
|
# part: y
|
||||||
def protected_split( openchar, closechar, splitchar, s, nesting_level = 0 )
|
def protected_split( openchar, closechar, splitchar, s, nesting_level = 0 )
|
||||||
result_array = Array.new
|
result_array = []
|
||||||
part = ""
|
part = ""
|
||||||
char = ""
|
char = ""
|
||||||
s.each_byte do |c|
|
s.each_byte do |c|
|
||||||
|
|
@ -150,6 +180,13 @@ def protected_split( openchar, closechar, splitchar, s, nesting_level = 0 )
|
||||||
return result_array
|
return result_array
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def enumerate_template_parameters( name )
|
||||||
|
if name =~ /^[^<]+[<](.*)[>]$/ then
|
||||||
|
return protected_split( '<', '>', ',', $1 )
|
||||||
|
else
|
||||||
|
return []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def split_typename( decl )
|
def split_typename( decl )
|
||||||
nesting_level = 0
|
nesting_level = 0
|
||||||
|
|
@ -173,8 +210,9 @@ def split_typename( decl )
|
||||||
return result, ""
|
return result, ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_argnames( decl, typemap )
|
def remove_argnames( decl)
|
||||||
result = ""
|
result = ""
|
||||||
|
$log.debug " removing argnames and default values/normalizing type modifiers in #{decl} :"
|
||||||
until decl =~ /^[)]/ || decl == "" do
|
until decl =~ /^[)]/ || decl == "" do
|
||||||
type_with_default, decl = split_typename( decl )
|
type_with_default, decl = split_typename( decl )
|
||||||
$log.debug " type with default: #{type_with_default}"
|
$log.debug " type with default: #{type_with_default}"
|
||||||
|
|
@ -184,102 +222,120 @@ def remove_argnames( decl, typemap )
|
||||||
else
|
else
|
||||||
type = type_with_default
|
type = type_with_default
|
||||||
end
|
end
|
||||||
|
$log.debug " type without default: #{type}"
|
||||||
# remove argname (preserving declarators like * and [])
|
# remove argname (preserving declarators like * and [])
|
||||||
if type =~ /\s*(\*+)?\s*\w+(\[\w+\])?$/ then
|
if type =~ /\s*(\*+)?\s*\w+((\[\w+\])+)?\s*$/ then
|
||||||
type = $`
|
type = $`
|
||||||
type += $1 if $1 != nil
|
type += $1 if $1 != nil
|
||||||
type += $2 if $2 != nil
|
if $2 != nil then
|
||||||
|
type += $2.gsub( /\w/, "" )
|
||||||
end
|
end
|
||||||
if typemap.has_key?( type ) then
|
$log.debug " normalized type: #{type}"
|
||||||
type = typemap[type]
|
|
||||||
end
|
end
|
||||||
result << type
|
result << type
|
||||||
if( decl =~ /,/ ) then
|
if( decl =~ /,/ ) then
|
||||||
result << ","
|
result << ","
|
||||||
decl = $'
|
decl = $'
|
||||||
end
|
end
|
||||||
$log.debug "type: [#{type}] \t ......rest: #{decl}"
|
$log.debug " type: #{type}\" \t rest: \"#{decl}"
|
||||||
end
|
end
|
||||||
return result + decl
|
return result + decl
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
#def match_and_consume( s, regex_string )
|
|
||||||
# printf " match: [#{regex_string}] .. "
|
|
||||||
# regex = Regexp.new( regex_string )
|
|
||||||
# if s =~ regex then
|
|
||||||
# s = s.sub( regex, "" )
|
|
||||||
# #puts "ok! remaining #{s}"
|
|
||||||
# return true
|
|
||||||
# end
|
|
||||||
# return false
|
|
||||||
#end
|
|
||||||
|
|
||||||
|
|
||||||
# convenience class
|
|
||||||
#class Declaration
|
|
||||||
# def initialize( name )
|
|
||||||
# @name = name
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def match( regex_string )
|
|
||||||
# name = match_and_consume( name, regex_string )
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
#end
|
|
||||||
|
|
||||||
class Doxygen
|
class Doxygen
|
||||||
def initialize( filename )
|
def initialize( filename )
|
||||||
@doxy_xml=XML::Document.file(filename)
|
@doxy_xml=XML::Document.file(filename)
|
||||||
@items = {}
|
@items = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def member_matches_texname?( memberdef, texname, strip_const_from_return_types )
|
def enumerate_template_parameters( memberdef )
|
||||||
is_const=""
|
retval = []
|
||||||
if memberdef['const'] == 'yes' then
|
memberdef.find( 'templateparamlist/param' ).each do |param|
|
||||||
is_const = "const"
|
retval << get_xpath_content(param,'declname')
|
||||||
end
|
end
|
||||||
|
return retval
|
||||||
|
end
|
||||||
|
|
||||||
|
def member_matches_texname?( memberdef, memberkind, is_static, texname ) # , strip_const_from_return_types
|
||||||
argsstring=get_xpath_content(memberdef,'argsstring')
|
argsstring=get_xpath_content(memberdef,'argsstring')
|
||||||
type=get_xpath_content(memberdef,'type')
|
type=get_xpath_content(memberdef,'type')
|
||||||
if strip_const_from_return_types then
|
#if strip_const_from_return_types then
|
||||||
type=type.gsub( /_const_/, "_" )
|
# type=type.gsub( /_const_/, "_" )
|
||||||
end
|
#end
|
||||||
name=get_xpath_content(memberdef,'name')
|
name=get_xpath_content(memberdef,'name')
|
||||||
|
template_parameters = enumerate_template_parameters( memberdef )
|
||||||
templateparamlist=""
|
templateparamlist=""
|
||||||
memberdef.find( 'templateparamlist/param' ).each do |param|
|
if template_parameters.length != 0 then
|
||||||
declname=get_xpath_content(param,'declname')
|
templateparamlist = "template<#{join(template_parameters,',')}>"
|
||||||
templateparamlist += declname+","
|
|
||||||
end
|
|
||||||
if templateparamlist != "" then
|
|
||||||
templateparamlist.gsub!( /,$/, "" )
|
|
||||||
templateparamlist = "template<#{templateparamlist}>"
|
|
||||||
end
|
end
|
||||||
doxyname=templateparamlist+"#{type} #{name}#{argsstring};"
|
doxyname=templateparamlist+"#{type} #{name}#{argsstring};"
|
||||||
doxyname=normalize_function_declaration( doxyname )
|
#$log.moreinfo " doxyname_pre: #{doxyname}"
|
||||||
|
doxyname=normalize_declaration( doxyname, memberkind )
|
||||||
$log.moreinfo " doxyname : #{doxyname}"
|
$log.moreinfo " doxyname : #{doxyname}"
|
||||||
return doxyname == texname
|
name_match = doxyname == texname
|
||||||
|
attrib_match = (memberdef['static'] == 'yes') == is_static
|
||||||
|
if name_match && !attrib_match then
|
||||||
|
$log.warning " name match, but no attrib match"
|
||||||
|
end
|
||||||
|
return name_match && attrib_match
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_member( compoundname, memberkind, texname )
|
def find_compound( compoundname, template_parameters )
|
||||||
$log.moreinfo "-- raw texname: "+texname
|
|
||||||
texname=normalize_function_declaration( texname )
|
|
||||||
$log.moreinfo "- find_member"
|
|
||||||
$log.moreinfo "-- compoundname: #{compoundname}"
|
$log.moreinfo "-- compoundname: #{compoundname}"
|
||||||
$log.moreinfo "-- memberkind: #{memberkind}"
|
|
||||||
$log.moreinfo "-- texname: #{texname}"
|
|
||||||
xpath_ckind='(@kind=\'struct\' or @kind=\'class\' or @kind=\'namespace\')'
|
xpath_ckind='(@kind=\'struct\' or @kind=\'class\' or @kind=\'namespace\')'
|
||||||
xpath_cname="(compoundname=\'#{compoundname}\')"
|
xpath_cname="(compoundname=\'#{compoundname}\')"
|
||||||
xpath_mkind="(@kind=\'#{memberkind}\')"
|
xpath_compound="/doxygen/compounddef[#{xpath_ckind}]" # and #{xpath_cname}]"
|
||||||
#xpath_mname="(name=\'#{membername}\')"
|
@doxy_xml.find( xpath_compound ).each do |compounddef|
|
||||||
xpath_compound="/doxygen/compounddef[#{xpath_ckind} and #{xpath_cname}]"
|
name=get_xpath_content( compounddef, "compoundname" )
|
||||||
xpath_member="/sectiondef/memberdef[#{xpath_mkind}]" # and #{xpath_mname}
|
template_values = ""
|
||||||
xpath_query="#{xpath_compound}#{xpath_member}"
|
if name =~ /^([^<]+)<(.*)>/ then
|
||||||
#puts "xpath query: #{xpath_query}"
|
name = $1
|
||||||
|
parameters = $2
|
||||||
|
end
|
||||||
|
if name == compoundname &&
|
||||||
|
compounddef.find('templateparamlist/param').length == template_parameters.length
|
||||||
|
then
|
||||||
|
return compounddef
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
for strip_const_from_return_type in [false,true]
|
def find_member( compounddef, memberkind, is_static, texname )
|
||||||
@doxy_xml.find( xpath_query ).each do |memberdef|
|
$log.moreinfo "- find_member"
|
||||||
if member_matches_texname?( memberdef, texname, strip_const_from_return_type )
|
$log.moreinfo "-- memberkind: #{memberkind}"
|
||||||
return memberdef
|
$log.moreinfo "-- texname: #{texname}"
|
||||||
|
xpath_mkind="(@kind=\'#{memberkind}\')"
|
||||||
|
xpath_member="sectiondef/memberdef[#{xpath_mkind}]" # and #{xpath_mname}
|
||||||
|
|
||||||
|
compounddef.find( xpath_member ).each do |memberdef|
|
||||||
|
if member_matches_texname?( memberdef, memberkind, is_static, texname )
|
||||||
|
if is_static then
|
||||||
|
texname = "static #{texname}"
|
||||||
|
end
|
||||||
|
location = memberdef.find( 'location' ).to_a.first
|
||||||
|
fail if location == nil
|
||||||
|
return location
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# additionally, look also for inner classes
|
||||||
|
compounddef.find( "innerclass" ).each do |innerclass|
|
||||||
|
name=innerclass.to_s
|
||||||
|
if name =~ /::([^:]+)$/ then
|
||||||
|
name = $1
|
||||||
|
end
|
||||||
|
if name == texname then
|
||||||
|
# TODO: template parameters ?
|
||||||
|
compoundname = get_xpath_content( compounddef, 'compoundname' )
|
||||||
|
compoundname += "::#{name}"
|
||||||
|
compounddef=find_compound( compoundname, [] )
|
||||||
|
if compounddef != nil then
|
||||||
|
location = compounddef.find( 'location' ).to_a.first
|
||||||
|
fail if location == nil
|
||||||
|
return location
|
||||||
|
else
|
||||||
|
$log.error( "did not find compound #{compoundname}" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -293,41 +349,86 @@ class Tex
|
||||||
@doxy = doxy
|
@doxy = doxy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# tex refpage, tex item, doxy location
|
||||||
|
def found_match( refpage, item, name, location )
|
||||||
|
pwd = Dir.pwd
|
||||||
|
filename = location['file']
|
||||||
|
line = location['line']
|
||||||
|
if filename =~ /^#{pwd}\// then
|
||||||
|
filename = $'
|
||||||
|
end
|
||||||
|
$log.info " found #{name} \tin #{filename} \t@ #{line}"
|
||||||
|
end
|
||||||
|
|
||||||
def list_all_refpages()
|
def list_all_refpages()
|
||||||
@tex_xml.find('/manual_tools_output/package').each do |package|
|
@tex_xml.find('/manual_tools_output/package').each do |package|
|
||||||
$log.info "package: #{package['id']}"
|
$log.info "package: #{package['id']}"
|
||||||
package.find('refpage[refcat!=\'Concept\']').each do |refpage|
|
package.find('refpage[refcat!=\'Concept\']').each do |refpage|
|
||||||
scope=get_xpath_content(refpage,'globalscope')
|
globalscope=get_xpath_content(refpage,'globalscope')
|
||||||
|
localscope=get_xpath_content(refpage,'localscope')
|
||||||
|
scope="#{globalscope}#{localscope}"
|
||||||
refcat=get_xpath_content(refpage,'refcat')
|
refcat=get_xpath_content(refpage,'refcat')
|
||||||
|
definition=get_xpath_content(refpage,'definition')
|
||||||
|
template_parameters = enumerate_template_parameters( definition )
|
||||||
compoundname = "#{scope}#{refpage['id']}" # if applicable
|
compoundname = "#{scope}#{refpage['id']}" # if applicable
|
||||||
case refcat
|
case refcat
|
||||||
when /Function/ then compoundname=scope.gsub( /::$/, '' )
|
when /Function/ then compoundname=scope.gsub( /::$/, '' )
|
||||||
end
|
end
|
||||||
|
look_for_static_memberfunctions = refcat == 'Concept' || refcat == 'Class'
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: scope may have template parameters. problem: doxygen xml output has problems with this:
|
||||||
|
# params only appear as prefix in members of compound, not in compound name
|
||||||
|
$log.info "refpage id: #{refpage['id']} scope: #{scope} refcat: #{refcat} name: #{definition}"
|
||||||
|
compounddef = @doxy.find_compound( compoundname, template_parameters )
|
||||||
|
if compounddef == nil then
|
||||||
|
$log.error( "cannot find compound '#{compoundname}'" )
|
||||||
|
next # refpage
|
||||||
|
else
|
||||||
|
$log.info("found compound #{compoundname}")
|
||||||
|
end
|
||||||
|
|
||||||
$log.info "refpage id: #{refpage['id']} \tscope: #{scope} \trefcat: #{refcat}"
|
|
||||||
refpage.find('item').each do |item|
|
refpage.find('item').each do |item|
|
||||||
name=get_xpath_content(item,'name')
|
|
||||||
kind=get_xpath_content(item,'kind')
|
kind=get_xpath_content(item,'kind')
|
||||||
comment=get_xpath_content(item,'comment')
|
|
||||||
#puts " item name: #{name}"
|
|
||||||
#puts " item kind: #{kind}"
|
|
||||||
#puts " item comment: #{comment}"
|
|
||||||
|
|
||||||
$log.moreinfo "compoundname: #{compoundname}"
|
|
||||||
|
|
||||||
if kind == "memberfunction" || kind == "constructor" then
|
if kind == "memberfunction" || kind == "constructor" then
|
||||||
kind="function"
|
kind="function"
|
||||||
elsif kind == "nested_type" then
|
elsif kind == "nested_type" then
|
||||||
kind="typedef"
|
kind="typedef"
|
||||||
end
|
end
|
||||||
|
|
||||||
memberdef=@doxy.find_member( compoundname , kind, name )
|
membername=normalize_declaration( get_xpath_content(item,'name'), kind )
|
||||||
if memberdef == nil then
|
comment=get_xpath_content(item,'comment')
|
||||||
$log.error "did not find doxygen equivalent for \"#{name}\" in \"#{compoundname}\""
|
is_static = false
|
||||||
else
|
|
||||||
definition=get_xpath_content(memberdef,'definition')
|
if look_for_static_memberfunctions &&
|
||||||
$log.info "OK! found memberdef: #{definition}"
|
(kind == 'function' || kind == 'memberfunction' )
|
||||||
|
then
|
||||||
|
if membername =~ /^[^ (]+\s#{refpage['id']}::(\w+)\s*\(/ then
|
||||||
|
membername = "#{$`} #{$1}(#{$'}"
|
||||||
|
is_static = true
|
||||||
end
|
end
|
||||||
|
if membername =~ /^\s*static\s*/ then
|
||||||
|
membername = $'
|
||||||
|
is_static = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if get_xpath_content(item,'kind') == 'constructor' then
|
||||||
|
if membername =~ /^#{refpage['id']}<.+>\(/ then
|
||||||
|
#puts "found template constructor #{membername}"
|
||||||
|
membername = "#{refpage['id']}(#{$'}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
$log.moreinfo "compoundname: #{compoundname}"
|
||||||
|
|
||||||
|
location=@doxy.find_member( compounddef, kind, is_static, membername )
|
||||||
|
if location != nil then
|
||||||
|
found_match( refpage, item, membername, location )
|
||||||
|
else
|
||||||
|
$log.error "did not find doxygen equivalent for member '#{membername}'"
|
||||||
|
end
|
||||||
|
|
||||||
end # each item
|
end # each item
|
||||||
end # each refpage
|
end # each refpage
|
||||||
end # each package
|
end # each package
|
||||||
|
|
@ -336,7 +437,9 @@ class Tex
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_xpath_content( node, xpath )
|
def get_xpath_content( node, xpath )
|
||||||
s=node.find( xpath ).to_a.first.to_s
|
nodes=node.find( xpath ).to_a
|
||||||
|
qreturn "" if nodes == nil
|
||||||
|
s = nodes.first.to_s
|
||||||
if s == nil then
|
if s == nil then
|
||||||
return ""
|
return ""
|
||||||
else
|
else
|
||||||
|
|
@ -346,6 +449,19 @@ end
|
||||||
|
|
||||||
|
|
||||||
$log = Logger.new
|
$log = Logger.new
|
||||||
|
$force_rebuild = false
|
||||||
|
|
||||||
|
def process_cmdline_options
|
||||||
|
pkg_hash = Hash.new
|
||||||
|
pkg_list = []
|
||||||
|
|
||||||
|
add_pkg = lambda { |name|
|
||||||
|
if name =~ /^(.+)_ref$/ then
|
||||||
|
pkg_hash[ $1 ] = true
|
||||||
|
else
|
||||||
|
pkg_hash[ name ] |= false
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
for x in 0...ARGV.length do
|
for x in 0...ARGV.length do
|
||||||
case ARGV[x]
|
case ARGV[x]
|
||||||
|
|
@ -354,28 +470,162 @@ for x in 0...ARGV.length do
|
||||||
$log.decrease_level( $1.length )
|
$log.decrease_level( $1.length )
|
||||||
end
|
end
|
||||||
$log.decrease_level( 1 )
|
$log.decrease_level( 1 )
|
||||||
when /^-doxy$/
|
when /^--rebuild$/
|
||||||
x += 1
|
$force_rebuild = true
|
||||||
fail "-doxy needs an argument" unless x < ARGV.length
|
when /^-/
|
||||||
doxyfilename = ARGV[x]
|
puts "! unknown command line option #{ARGV[x]}"
|
||||||
when /^-tex$/
|
else
|
||||||
x += 1
|
add_pkg[ ARGV[x] ]
|
||||||
fail "-tex needs an argument" unless x < ARGV.length
|
|
||||||
texfilename = ARGV[x]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fail "-doxy and -tex are required" if texfilename == nil || doxyfilename == nil
|
if pkg_hash.length == 0 then
|
||||||
|
#puts "autofind"
|
||||||
|
raise unless Dir.chdir("doc_tex")
|
||||||
|
for pkg in Dir["*"]
|
||||||
|
if File.directory?( pkg ) && File.file?( "#{pkg}/main.tex" ) then
|
||||||
|
#puts " found pkg: #{pkg}"
|
||||||
|
add_pkg[ pkg ]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
raise unless Dir.chdir("..")
|
||||||
|
end
|
||||||
|
pkg_hash.keys.each do |key|
|
||||||
|
if pkg_hash[key] then
|
||||||
|
pkg_list.push( [key, "#{key}_ref"] )
|
||||||
|
#puts "#{key} #{key}_ref"
|
||||||
|
else
|
||||||
|
pkg_list.push( [key, nil ] )
|
||||||
|
#puts key
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return pkg_list
|
||||||
|
end
|
||||||
|
|
||||||
doxy = Doxygen.new( doxyfilename )
|
def have_to_rebuild?( gen_filename, dep_path, dep_pattern )
|
||||||
tex = Tex.new( texfilename, doxy )
|
return true if $force_rebuild
|
||||||
|
retval = false
|
||||||
|
if File.file?( gen_filename ) then
|
||||||
|
mtime = File.mtime( gen_filename )
|
||||||
|
Dir.chdir(dep_path)
|
||||||
|
for f in Dir[dep_pattern]
|
||||||
|
if mtime < File.mtime( f ) then
|
||||||
|
retval = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Dir.chdir("..")
|
||||||
|
return retval
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
def have_to_rebuild_comments_xml?( pkg )
|
||||||
|
texfilename = "doc_html/#{pkg}/comments.xml"
|
||||||
|
return have_to_rebuild?( texfilename, "doc_tex", "**/*.tex" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def have_to_rebuild_doxy_xml?
|
||||||
|
doxyfilename = "include/xml/all.xml"
|
||||||
|
return have_to_rebuild?( doxyfilename, "include", "**/*.h" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def ensure_cmd( cmd )
|
||||||
|
`which #{cmd}`
|
||||||
|
raise "#{cmd} is required" unless $? == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_requirements
|
||||||
|
ensure_cmd( "cgal_manual" )
|
||||||
|
ensure_cmd( "latex_to_html" )
|
||||||
|
ensure_cmd( "doxygen" )
|
||||||
|
ensure_cmd( "xsltproc" )
|
||||||
|
end
|
||||||
|
|
||||||
|
# returns a list of relative paths to */comment.xml files
|
||||||
|
def check_doc_tex_and_doxy_xml
|
||||||
|
pkg_list = process_cmdline_options
|
||||||
|
pkg_list.each do |pkg|
|
||||||
|
if have_to_rebuild_comments_xml?( pkg[0] ) then
|
||||||
|
puts
|
||||||
|
puts "***********************************************************************"
|
||||||
|
puts "* rebuilding html manual for #{pkg[0]} ..."
|
||||||
|
puts "***********************************************************************"
|
||||||
|
|
||||||
|
Dir.chdir("doc_tex")
|
||||||
|
output=`cgal_manual -html #{pkg[0]} #{pkg[1]}`
|
||||||
|
if $? == 256 then
|
||||||
|
puts output
|
||||||
|
#errormsg=`cat #{pkg[0]}.hlg`
|
||||||
|
#fail errormsg
|
||||||
|
else
|
||||||
|
puts "OK."
|
||||||
|
end
|
||||||
|
Dir.chdir("..")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if have_to_rebuild_doxy_xml? then
|
||||||
|
puts
|
||||||
|
puts "***********************************************************************"
|
||||||
|
puts "* rebuilding doxygen ..."
|
||||||
|
puts "***********************************************************************"
|
||||||
|
|
||||||
|
Dir.chdir("include")
|
||||||
|
doxyfile=File.open( "Doxyfile", "w" )
|
||||||
|
doxyfile.write <<DOXY_EOF
|
||||||
|
SORT_BY_SCOPE_NAME = NO
|
||||||
|
SHOW_DIRECTORIES = NO
|
||||||
|
WARNINGS = NO
|
||||||
|
RECURSIVE = YES
|
||||||
|
FILTER_SOURCE_FILES = YES
|
||||||
|
INPUT_FILTER = "sed -e 's/CGAL_BEGIN_NAMESPACE/namespace CGAL {/' -e 's/CGAL_END_NAMESPACE/}/'"
|
||||||
|
SOURCE_BROWSER = NO
|
||||||
|
VERBATIM_HEADERS = NO
|
||||||
|
GENERATE_HTML = NO
|
||||||
|
GENERATE_XML = YES
|
||||||
|
GENERATE_LATEX = NO
|
||||||
|
XML_OUTPUT = xml
|
||||||
|
XML_PROGRAMLISTING = NO
|
||||||
|
ENABLE_PREPROCESSING = YES
|
||||||
|
SEARCH_INCLUDES = YES
|
||||||
|
SKIP_FUNCTION_MACROS = YES
|
||||||
|
PERL_PATH = /usr/bin/perl
|
||||||
|
DOXY_EOF
|
||||||
|
doxyfile.close
|
||||||
|
output=`doxygen >& /dev/null`
|
||||||
|
if $? != 0 then
|
||||||
|
puts output
|
||||||
|
raise "!! doxygen error."
|
||||||
|
else
|
||||||
|
puts "OK."
|
||||||
|
end
|
||||||
|
Dir.chdir("xml")
|
||||||
|
output=`xsltproc combine.xslt index.xml > all.xml`
|
||||||
|
if $? != 0 then
|
||||||
|
puts output
|
||||||
|
raise "!! xsltproc error."
|
||||||
|
end
|
||||||
|
Dir.chdir("../..")
|
||||||
|
end
|
||||||
|
return pkg_list
|
||||||
|
end
|
||||||
|
|
||||||
|
def main
|
||||||
|
internal_test
|
||||||
|
check_requirements
|
||||||
|
pkg_list = check_doc_tex_and_doxy_xml
|
||||||
|
doxy = Doxygen.new( "include/xml/all.xml" )
|
||||||
|
pkg_list.each do |pkg|
|
||||||
|
puts "***********************************************************************"
|
||||||
|
puts "* processing package #{pkg[0]} ..."
|
||||||
|
puts "***********************************************************************"
|
||||||
|
tex = Tex.new( "doc_html/#{pkg[0]}/comments.xml", doxy )
|
||||||
tex.list_all_refpages
|
tex.list_all_refpages
|
||||||
|
end
|
||||||
|
puts "+------+"
|
||||||
|
puts "| done |"
|
||||||
|
puts "+------+"
|
||||||
|
end
|
||||||
|
|
||||||
#s = remove_argnames( "long int bla=CGAL::my_default_value<xxx<yyy>::bla>,bool blubb)" )
|
main
|
||||||
#s = remove_argnames( "void bla(type<param> bla,bool blubb,float x)const;" )
|
|
||||||
#s = normalize_declaration( "void bla(NT values[D],int *bla = default);" )
|
|
||||||
#puts "result: #{s}"
|
|
||||||
|
|
||||||
#puts normalize_function_declaration( "template<class XX, typename YY=bla<blubb> >void bla(XX a, XX b, YY c)" #)
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue