# AutoDoc: Generate documentation from GAP source code # # Copyright of AutoDoc belongs to its developers. # Please refer to the COPYRIGHT file for details. # # SPDX-License-Identifier: GPL-2.0-or-later
##
InstallMethod( DocumentationTree, [ ], function( )
local tree;
tree := rec(
content := [ ], # a list of nodes
nodes_by_label := rec( ),
node_name_iterator := 0,
current_level := 0,
TitlePage := rec( ),
chunks := rec( ),
);
ObjectifyWithAttributes( tree, TheTypeOfDocumentationTrees );
return tree; end );
## create a chapter, section or subsection
InstallMethod( StructurePartInTree, [ IsTreeForDocumentation, IsList ], function( tree, context )
local label, parent, new_node, type;
if IsEmpty( context ) then
return tree; fi;
# if the part already exist, use that
label := AUTODOC_LABEL_OF_CONTEXT( context ); if IsBound( tree!.nodes_by_label.( label ) ) then
return tree!.nodes_by_label.( label ); fi;
stream := AUTODOC_OutputTextFile( path_to_xmlfiles, _AUTODOC_GLOBAL_OPTION_RECORD.AutoDocMainFile );
AppendTo( stream, AUTODOC_XML_HEADER ); for i in tree!.content do if not IsTreeForDocumentationNodeForChapterRep( i ) then
Error( "this should never happen" ); fi; ## FIXME: If there is anything else than a chapter, this will break!
WriteDocumentation( i, stream, path_to_xmlfiles, level_value );
od;
if node!.level > level_value then
return; fi; if ForAll( node!.content, IsEmptyNode ) then
return; fi;
if IsBound( node!.title_string ) then
replaced_name := NormalizedWhitespace( node!.title_string ); else
replaced_name := ReplacedString( node!.name, "_", " " ); fi;
# Remove any characters outside of A-Za-z0-9 and -, +, _ from the filename. # See issues #77 and #78
filename := Filtered( Label( node ), x -> x in AUTODOC_IdentifierLetters);
filename := Concatenation( "_", filename, ".xml" );
chapter_stream := AUTODOC_OutputTextFile( path_to_xmlfiles, filename );
AppendTo( stream, "<#Include SYSTEM \"", filename, "\">\n" );
AppendTo( chapter_stream, AUTODOC_XML_HEADER );
AppendTo( chapter_stream, "<Chapter Label=\"", Label( node ) ,"\">\n" );
AppendTo( chapter_stream, Concatenation( [ "<Heading>", replaced_name, "</Heading>\n\n" ] ) );
WriteDocumentation( node!.content, chapter_stream, level_value );
AppendTo( chapter_stream, "</Chapter>\n\n" );
CloseStream( chapter_stream ); end );
##
InstallMethod( WriteDocumentation, [ IsList, IsStream, IsInt ], function( node_list, filestream, level_value )
local current_string_list, i, last_position;
i := 1;
current_string_list := [ ]; for i in [ 1 .. Length( node_list ) ] do if IsString( node_list[ i ] ) then
Add( current_string_list, ShallowCopy( node_list[ i ] ) ); else if current_string_list <> [ ] then
current_string_list := CONVERT_LIST_OF_STRINGS_IN_MARKDOWN_TO_GAPDOC_XML( current_string_list );
Perform( current_string_list, function( i ) WriteDocumentation( i, filestream, level_value ); end );
current_string_list := [ ]; fi;
WriteDocumentation( node_list[ i ], filestream, level_value );
AppendTo( filestream, "\n" ); fi;
od; if current_string_list <> [ ] then
current_string_list := CONVERT_LIST_OF_STRINGS_IN_MARKDOWN_TO_GAPDOC_XML( current_string_list );
Perform( current_string_list, function( i ) WriteDocumentation( i, filestream, level_value ); end ); fi; end );
##
InstallMethod( WriteDocumentation, [ IsString, IsStream, IsInt ], function( text, filestream, level_value ) ## In case the list is empty, do nothing. ## Once the empty string = empty list bug is fixed, ## this could be removed.
text := Chomp( text ); if NormalizedWhitespace( text ) = ""then
return; fi;
AppendTo( filestream, text, "\n" ); end );
##
InstallMethod( WriteDocumentation, [ IsTreeForDocumentationExampleNodeRep, IsStream, IsInt ], function( node, filestream, level_value )
local contents, i, tested, inserted_string;
if node!.level > level_value then
return; fi;
contents := node!.content;
tested := node!.is_tested_example; if tested = true then
inserted_string := "Example"; elif tested = false then
inserted_string := "Log"; else
Error( "This should not happen!" ); fi;
AppendTo( filestream, "<", inserted_string, "><![CDATA[\n" ); for i in contents do # We wrap the data into a CDATA section; make sure that the content # of the example does not accidentally end the CDATA section prematurely; # to do this, we concatenate multiple CDATA sections: # first we insert ]], then we end the CDATA section, then we start # a new CDATA section which starts with >.
i := ReplacedString(i, "]]>", "]]]]><![CDATA[>");
AppendTo( filestream, i, "\n" );
od;
AppendTo( filestream, "]]></", inserted_string, ">\n\n" ); end );
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet am 2026-10-13)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.