Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<p>Contributing to online documentation website <a href="http://gotapi.com">http://gotapi.com</a>, we have to generate a xml document describing groovy objects and methods hierarchy and links to javadoc.</p> <p>This is done with the following groovy script and the excellent HTML parser NekoHTML (see <a href="http://people.apache.org/~andyc/neko/doc/index.html">http://people.apache.org/~andyc/neko/doc/index.html</a> ) <br class="atl-forced-newline" /></p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> package free.cafekiwi.gotapi; import groovy.xml.MarkupBuilder /** * @author Marc DEXET **/ class XmlGotApiGenerator { static void main(args) { def writer = new FileWriter( new File('gotapi.xml')) def xml = new MarkupBuilder(writer) def pages = [] def apidocRoot = 'http://groovy.codehaus.org/api' def parser = new JavaDocParser(); def methodNameFilter = { anchor -> def name = anchor.'@name' name != null && name.indexOf('(') >=0 } def packageFilter = { anchor -> def url = anchor.'@href' url != null && url.endsWith( "/package-frame.html") } def classFilter = { anchor -> def url = anchor.'@href' url != null && ! url.contains ('/') } def parseAndGet = { url, filter -> parser.parse( url ).depthFirst().A.findAll( filter ) } parseAndGet("$apidocRoot/overview-frame.html", packageFilter).each { def packBaseURL = it.'@href' - "/package-frame.html" def packPage = new Page( title: packBaseURL.replace('/', '.') , type: 'package', url: "${apidocRoot}/${it.'@href'}" ); pages << packPage println "PackPAGE ${packPage}" parseAndGet( packPage.url, classFilter).each { def url = it.'@href' def fullUrl = "${apidocRoot}/${packBaseURL}/${url}" def fqn = url.replace('/', '.')- ".html" def parts = fqn.tokenize('.') def classPage = new Page( title: fqn , type: 'class', url: fullUrl ); packPage.children << classPage println "Class PAGE: ${classPage}" parseAndGet( classPage.url, methodNameFilter ).each { def methodeName = it.'@name' def methodPage = new Page( title: methodeName , type: 'method', url: classPage.url+'#'+methodeName); classPage.children << methodPage println "Method PAGE: ${methodPage}" } } } xml.pages() { pages.each{ packIt -> xml.page(title: packIt.title , type: packIt.type, url: packIt.url) { packIt.children.each { classIt -> xml.page(title: classIt.title , type: classIt.type, url: classIt.url) { classIt.children.each { methodIt -> xml.page(title: methodIt.title , type: methodIt.type, url: methodIt.url) } } } } } } println 'END' } } class Page { def title def type def url def children = [] public String toString() { "Titre: ${title} Type: ${type} URL:${url} \\n\\t ${children.collect{it.toString()+'\\n\\t' }}" } } class JavaDocParser { def parser /* Constructor */ JavaDocParser() { def nekoparser = new org.cyberneko.html.parsers.SAXParser() nekoparser.setFeature('http://xml.org/sax/features/namespaces', false) parser = new XmlParser(nekoparser); } def parse(url) { return parser.parse(url) } } </pre></td></tr></table> <p><br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <br class="atl-forced-newline" /></p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced