From 90825e2392b2d70e43c7a25b8a3752299a933894 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kjsembed/docs/build-docs.js | 230 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 kjsembed/docs/build-docs.js (limited to 'kjsembed/docs/build-docs.js') diff --git a/kjsembed/docs/build-docs.js b/kjsembed/docs/build-docs.js new file mode 100644 index 00000000..04f276c1 --- /dev/null +++ b/kjsembed/docs/build-docs.js @@ -0,0 +1,230 @@ +#!/usr/bin/env kjscmd + +function write_page( name, body ) +{ + var markUp = ""; + + markUp += '\n'; + + markUp += '\n'; + markUp += '' + name + '\n'; + markUp += '\n'; + markUp += '\n'; + + markUp += '\n'; + markUp += 'All Objects'; + markUp += '| Statics'; + markUp += '| Objects'; + markUp += '| KJSEmbed Objects'; + markUp += '| Qt Objects'; + markUp += '| KDE Objects'; + markUp += '| Exceptions'; + markUp += '| Uncreatable Objects\n'; + markUp += '

' + name + '

\n'; + markUp += '
\n'; + markUp += body; + markUp += '
\n'; + markUp += '\n'; + + markUp += '\n'; + return markUp; +} + +function write_classlist( title, intro, classlist ) +{ + text = '

'+title+'

'; + text += intro; + text += '\n'; + + return text; +} + +function write_classes( title, desc, sections ) +{ + var txt = desc; + for ( var i = 0; i < sections.length; i += 3 ) { + txt += write_classlist( sections[ i ], sections[ i+1 ], sections[ i+2 ] ); + } + + return write_page( title, txt ); +} + +function generate_docs_object( name, obj ) +{ + var fileText = write_page( name, + 'Bindings for the ' + name + ' class.
' + dump(obj) ); + System.writeFile("jsref/" + name.toLowerCase() + ".html", fileText); +} + +function generate_docs_nocreate( name ) +{ + var fileText = write_page( name, + 'Bindings for the ' + name + ' class.
' + + 'This class is understood by the interpreter, but cannot be created from scripts.' ); + + System.writeFile("jsref/" + name.toLowerCase() + ".html", fileText); +} + +// +// Document the static objects +// +function document_statics( statics ) +{ + for ( var idx = 0; idx < statics.length; idx++ ) { + var name = statics[idx]; + try + { + var obj = eval( name ); + var fileText = write_page( name, + 'Bindings for the static ' + name + ' object.' + dump(obj) ); + System.writeFile("jsref/" + name.toLowerCase() + ".html", fileText); + } + catch(x) + { + println("Error: " + x ); + } + } +} + +// +// Build script that will document the constructable objects +// + +function document_constructable( objects ) +{ + for ( var idx = 0; idx < objects.length; idx++ ) + { + println('Document class: ' + objects[idx] ); + + try { + generate_docs_object( objects[idx], Factory.createObject( objects[idx] )); + println(', Success'); + } + catch(x) { + println(', Error ' + x ); + generate_docs_nocreate( objects[idx] ); + nocreate.push( objects[idx] ); + } + } +} +//// +//// Main +//// + + +var statics = [ 'Factory', 'System', 'Global', 'StdDialog', + 'StdAction', 'StdDirs', 'StdIcons', 'Qt' ]; +qttps = []; +kdetps = []; +kjsetps = []; +other = []; +nocreate = []; +var expts = [ 'ReferenceError', 'EvalError', 'RangeError', 'TypeError' ]; +tps = Factory.types().sort(); + +statics.sort(); +expts.sort(); + +cons = Factory.constructors().sort(); +cons += 'Part'; + +for ( var i=0; i < tps.length; i++ ) { + + if ( /^Q/.test(tps[i]) ) { + qttps.push( tps[i] ); + } + else if ( /^KJSEmbed::/.test(tps[i]) ) { + if ( tps[i] != 'KJSEmbed::Bindings::JSDCOPInterface' ) { + kjsetps.push( tps[i] ); + } + } + else if ( /^K/.test(tps[i]) ) { + kdetps.push( tps[i] ); + } + else { + other.push( tps[i] ); + } +} + +// +// Generate object reference pages +// + +document_constructable( tps ); +document_statics( statics ); +document_statics( expts ); + +generate_docs_object( 'TextStream', System.stdin ); +generate_docs_object( 'Application', application ); +generate_docs_object( 'KJSEmbedPart', part ); +generate_docs_object( 'QListViewItem', new QListViewItem(new QListView()) ); +generate_docs_object( 'QCheckListItem', new QCheckListItem(new QListView()) ); +generate_docs_object( 'QCanvasText', new QCanvasText(new QCanvas()) ); + +other.push( 'Application' ); +other.sort(); + +// +// Generate index pages +// +index = [ 'Static Objects', + 'Statics that are available to scripts as JS objects.', + statics, + + 'Object Types', + 'The non-widget objects that are defined for scripts.', + other, + + 'KJSEmbed Objects', + 'KDE objects that are available to scripts as JS objects.', + kjsetps, + + 'Qt Objects', + 'Qt objects that are available to scripts as JS objects.', + qttps, + + 'KDE Objects', + 'KDE objects that are available to scripts as JS objects.', + kdetps, + + 'Exception Types', + 'Exceptions that are defined for scripts.', + expts, + + 'Unconstructable Types', + 'Known type that scripts cannot create.', + nocreate + ]; + +System.writeFile( "jsref/index.html", + write_classes( 'All Scriptable Objects', + 'The full set of objects that can be accessed by scripts.', + index ) ); + +System.writeFile( "jsref/index-static.html", write_classes( index[0], index[1], ['','',index[2]] ) ); +System.writeFile( "jsref/index-objects.html", write_classes( index[3], index[4], ['','',index[5]] ) ); +System.writeFile( "jsref/index-kjsembedobjects.html", write_classes( index[6], index[7], ['','',index[8]] ) ); +System.writeFile( "jsref/index-qtobjects.html", write_classes( index[9], index[10], ['','',index[11]] ) ); +System.writeFile( "jsref/index-kdeobjects.html", write_classes( index[12], index[13], ['','',index[14]] ) ); +System.writeFile( "jsref/index-exceptions.html", write_classes( index[15], index[16], ['','',index[17]] ) ); +System.writeFile( "jsref/index-nocreate.html", write_classes( index[18], index[19], ['','',index[20]] ) ); + +System.exit(0); -- cgit v1.2.1