mirror of https://github.com/apache/ant-ivy
Experimental xooki to asciidoc convertor
This commit is contained in:
parent
03542311e2
commit
879ac405ee
|
|
@ -0,0 +1,87 @@
|
|||
doctype transitional
|
||||
/!
|
||||
/! Licensed to the Apache Software Foundation (ASF) under one
|
||||
/! or more contributor license agreements. See the NOTICE file
|
||||
/! distributed with this work for additional information
|
||||
/! regarding copyright ownership. The ASF licenses this file
|
||||
/! to you under the Apache License, Version 2.0 (the
|
||||
/! "License"); you may not use this file except in compliance
|
||||
/! with the License. You may obtain a copy of the License at
|
||||
/!
|
||||
/! http://www.apache.org/licenses/LICENSE-2.0
|
||||
/!
|
||||
/! Unless required by applicable law or agreed to in writing,
|
||||
/! software distributed under the License is distributed on an
|
||||
/! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
/! KIND, either express or implied. See the License for the
|
||||
/! specific language governing permissions and limitations
|
||||
/! under the License.
|
||||
- page = IvyDocHelpers.page(attr("basedir"), attr("docfile"))
|
||||
html lang=(attr :lang, 'en' unless attr? :nolang)
|
||||
head
|
||||
meta http-equiv="Content-Type" content="text/html; charset=utf-8"
|
||||
meta name='generator' content="Asciidoctor #{attr 'asciidoctor-version'}"
|
||||
title=((doctitle :sanitize => true) || (attr 'untitled-label'))
|
||||
link rel="stylesheet" type="text/css" href="#{page.relativeRoot}style/style.css"
|
||||
script src="#{page.relativeRoot}js/jquery.pack.js" type="text/javascript"
|
||||
script src="#{page.relativeRoot}js/jquery.treeview.js" type="text/javascript"
|
||||
javascript:
|
||||
$(document).ready(function(){$("#treemenu").Treeview({speed: "fast",store: true});});
|
||||
body
|
||||
div id="body"
|
||||
table id="header" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%"
|
||||
tr
|
||||
td id="home" width="30%"
|
||||
a href="http://ant.apache.org/" title="Apache Ant"
|
||||
img src="#{page.relativeRoot}images/ant-group-logo.gif" alt="Apache Ant" border="0"/
|
||||
td class="product" width="70%" align="right" valign="middle"
|
||||
img src="#{page.relativeRoot}images/logo.png" alt="ivy" border="0"/
|
||||
table id="top-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%"
|
||||
tr
|
||||
td
|
||||
div id="navcontainer"
|
||||
a<> href="http://www.apache.org/" Apache™
|
||||
| >
|
||||
a<> href="http://ant.apache.org/" Apache Ant™
|
||||
| >
|
||||
a<> href="http://ant.apache.org/ivy/" Apache Ivy™
|
||||
| >
|
||||
= page.breadCrumb
|
||||
table id="content" border="0" cellpadding="0" cellspacing="0" width="100%"
|
||||
tr
|
||||
td id="sidebar-left"
|
||||
div class="block block-book" id="block-book-0"
|
||||
h2 Apache Ivy™
|
||||
div class="content"
|
||||
= page.menu()
|
||||
center
|
||||
iframe src="http://www.apache.org/ads/buttonbar.html" style="border-width:0;" frameborder="0" scrolling="no" width="135" height="265"
|
||||
td valign="top"
|
||||
div id="main"
|
||||
h1 class="title" = page.title
|
||||
#content=content
|
||||
table id="footer-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%"
|
||||
tr
|
||||
td align="center" valign="middle"
|
||||
div class="primary-links"
|
||||
| ::
|
||||
a href="index.html" Home
|
||||
| ::
|
||||
a href="reference.html" Reference
|
||||
| ::
|
||||
a href="tutorial.html" Tutorials
|
||||
| ::
|
||||
a href="dev.html" Developer's doc
|
||||
| ::
|
||||
div id="footer-message" class="footer"
|
||||
hr/
|
||||
i
|
||||
| Copyright © 2014 The Apache Software Foundation, Licensed under the
|
||||
a href="http://www.apache.org/licenses/LICENSE-2.0.txt" Apache License, Version 2.0
|
||||
| .
|
||||
br/
|
||||
i
|
||||
| Apache Ivy, Apache Ant, Ivy, Ant, Apache, the Apache Ivy logo, the Apache Ant logo and the Apache feather logo are trademarks of The Apache Software Foundation.
|
||||
br/
|
||||
i
|
||||
| All other marks mentioned may be trademarks or registered trademarks of their respective owners.
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
# Add custom functions to this module that you want to use in your Slim
|
||||
# templates. Within the template you must namespace the function
|
||||
# (unless someone can show me how to include them in the evaluation context).
|
||||
# You can change the namespace to whatever you want.
|
||||
|
||||
require 'json'
|
||||
|
||||
module IvyDocHelpers
|
||||
|
||||
class Page
|
||||
attr_accessor :id, :title, :url, :allChildIds, :children, :parent
|
||||
|
||||
def initialize()
|
||||
@id = ""
|
||||
@title = ""
|
||||
@url = ""
|
||||
@allChildIds = []
|
||||
@children = []
|
||||
@parent = nil
|
||||
end
|
||||
|
||||
def link(printpage)
|
||||
l = ''
|
||||
if self.url
|
||||
l += '<a href="' + printpage.relativeRoot + self.url + '"'
|
||||
if self.id == printpage.id
|
||||
l += ' class="current"'
|
||||
end
|
||||
l += '>' + self.title + '</a>'
|
||||
else
|
||||
l += self.title
|
||||
end
|
||||
return l
|
||||
end
|
||||
|
||||
def relativeRoot()
|
||||
p = ''
|
||||
(self.id.split("/").length-1).times do |e|
|
||||
p += '../'
|
||||
end
|
||||
return p
|
||||
end
|
||||
|
||||
def breadCrumb()
|
||||
b = '<span class="breadCrumb">'
|
||||
b += breadCrumbStep(self)
|
||||
b += '</span>'
|
||||
return b
|
||||
end
|
||||
|
||||
def breadCrumbStep(page)
|
||||
b = ' '
|
||||
if page.parent && page.parent.parent
|
||||
b += breadCrumbStep(page.parent)
|
||||
b += ' > '
|
||||
end
|
||||
b += page.link(page)
|
||||
return b
|
||||
end
|
||||
|
||||
def rootpage()
|
||||
if self.parent
|
||||
return self.parent.rootpage()
|
||||
else
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
def menu()
|
||||
return innermenu(rootpage())
|
||||
end
|
||||
|
||||
def innermenu(page)
|
||||
m = '<ul id="treemenu" class="treeview">' + "\n"
|
||||
page.children.each do |p|
|
||||
m += '<li id="xooki-' + p.id + '"'
|
||||
if p.children.length > 0
|
||||
m += ' class="submenu"'
|
||||
end
|
||||
m += '>'
|
||||
m += p.link(self)
|
||||
if p.children.length > 0
|
||||
m += '<ul class="'
|
||||
if p.allChildIds.include? self.id
|
||||
m += 'open'
|
||||
else
|
||||
m += 'closed'
|
||||
end
|
||||
m += '">'
|
||||
m += innermenu(p)
|
||||
m += '</ul>'
|
||||
end
|
||||
m += "</li>\n"
|
||||
end
|
||||
m += "</ul>\n"
|
||||
return m
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def self.page(basedir, docfile)
|
||||
rootpage = loadPages(basedir)
|
||||
pageId = docfile[basedir.length+1..docfile.rindex(/\./)-1]
|
||||
p = findPage(rootpage, pageId)
|
||||
if !p
|
||||
p = Page.new
|
||||
end
|
||||
return p
|
||||
end
|
||||
|
||||
def self.loadPages(basedir)
|
||||
rootpage = Page.new
|
||||
toc = JSON.parse(IO.read(basedir + "/toc.json"))
|
||||
toc['children'].each do |child|
|
||||
rootpage.children << loadPage(basedir, rootpage, child, "")
|
||||
end
|
||||
return rootpage
|
||||
end
|
||||
|
||||
def self.loadPage(basedir, parent, node, path)
|
||||
p = Page.new
|
||||
p.title = node['title']
|
||||
p.parent = parent
|
||||
if node.has_key?("importRoot")
|
||||
p.id = path + child['importRoot'] + '/' + node['importNode']
|
||||
p.url = p.id + ".html"
|
||||
toc = JSON.parse(IO.read(basedir + '/' + child['importRoot'] + "/toc.json"))
|
||||
toc['children'].each do |child|
|
||||
p.children << loadPage(basedir, p, child, path + child['importRoot'] + '/')
|
||||
end
|
||||
else
|
||||
p.id = node['id']
|
||||
if !(node.has_key?("isAbstract"))
|
||||
if node.has_key?("url")
|
||||
p.url = node['url']
|
||||
else
|
||||
p.url = path + node['id'] + ".html"
|
||||
end
|
||||
end
|
||||
if node.has_key?("children")
|
||||
node['children'].each do |child|
|
||||
p.children << loadPage(basedir, p, child, path)
|
||||
end
|
||||
end
|
||||
end
|
||||
p.children.each { |cp| p.allChildIds += cp.allChildIds }
|
||||
if p.id
|
||||
p.allChildIds << p.id
|
||||
end
|
||||
return p
|
||||
end
|
||||
|
||||
def self.findPage(parent, pageId)
|
||||
parent.children.each do |p|
|
||||
if p.id == pageId
|
||||
return p
|
||||
end
|
||||
if p.children.length > 0
|
||||
found = findPage(p, pageId)
|
||||
if found
|
||||
return found
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<project name="doc" xmlns:ivy="antlib:org.apache.ivy.ant"
|
||||
xmlns:xooki="antlib:xooki"
|
||||
xmlns:asciidoctor="antlib:org.asciidoctor.ant">
|
||||
<import file="build-release.xml"/>
|
||||
|
||||
<target name="generate-asciidoc" depends="generate-doc-init">
|
||||
<mkdir dir="${build.dir}/asciidoc" />
|
||||
<!-- requires java 6 jdk in path and Apache Ant 1.7 -->
|
||||
<taskdef uri="antlib:xooki" file="${doc.src.dir}/xooki2asciidoc/antlib.xml" />
|
||||
<xooki:toAsciidoc destDir="${build.dir}/asciidoc" checkUpToDate="true" xookidir="${doc.src.dir}/xooki2asciidoc">
|
||||
<fileset dir="${doc.tmp.dir}">
|
||||
<include name="**/*.html"/>
|
||||
<exclude name="template*.html"/>
|
||||
<exclude name="*Template.html"/>
|
||||
<exclude name="conflict-solving-algo.html"/>
|
||||
<exclude name="use.html"/>
|
||||
<exclude name="samples/**"/>
|
||||
<exclude name="js/**"/>
|
||||
<exclude name="reports/**"/>
|
||||
<exclude name="xooki/**"/>
|
||||
</fileset>
|
||||
</xooki:toAsciidoc>
|
||||
<copy file="${doc.tmp.dir}/toc.json" todir="${build.dir}/asciidoc" />
|
||||
</target>
|
||||
|
||||
<target name="generate-doc" depends="init-ivy,generate-doc-init">
|
||||
<ivy:cachepath pathid="asciidoctor.path">
|
||||
<dependency org="org.asciidoctor" name="asciidoctor-ant" rev="1.5.0" />
|
||||
</ivy:cachepath>
|
||||
<taskdef uri="antlib:org.asciidoctor.ant" resource="org/asciidoctor/ant/antlib.xml" classpathref="asciidoctor.path" />
|
||||
<asciidoctor:convert sourceDirectory="${build.dir}/asciidoc" outputDirectory="${doc.build.dir}" backend="xhtml5" templateDir="asciidoc-template" preserveDirectories="true">
|
||||
<attribute key="basedir" value="${build.dir}/asciidoc" />
|
||||
</asciidoctor:convert>
|
||||
<copy todir="${doc.build.dir}">
|
||||
<fileset dir="${doc.src.dir}" includes="images/**,style/**,samples/**,js/**,ivy.xsd" />
|
||||
<fileset dir="${doc.tmp.dir}" includes="tutorial/log/multi-project-general-publishall.txt" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<antlib>
|
||||
<scriptdef name="toAsciidoc" language="javascript">
|
||||
<element name="fileset" type="fileset"/>
|
||||
<attribute name="destDir"/>
|
||||
<attribute name="xookidir"/>
|
||||
<attribute name="checkUpToDate"/>
|
||||
<attribute name="printerFriendly"/>
|
||||
<![CDATA[
|
||||
importClass(java.io.File);
|
||||
|
||||
var xookidir = attributes.get("xookidir");
|
||||
if (xookidir == null) {
|
||||
xookidir = project.getProperty("basedir") + "/xooki";
|
||||
}
|
||||
|
||||
filesets = elements.get("fileset")
|
||||
for (j = 0; j < filesets.size(); j++) {
|
||||
fs = filesets.get(j);
|
||||
srcDir = fs.getDir(project);
|
||||
|
||||
// Get the files (array) of that fileset
|
||||
ds = fs.getDirectoryScanner(project);
|
||||
srcFiles = ds.getIncludedFiles();
|
||||
|
||||
// iterate over that array
|
||||
print('processing ' + srcFiles.length + ' source files...');
|
||||
for (i = 0; i < srcFiles.length; i++) {
|
||||
|
||||
// get the values via Java API
|
||||
var file = new File(fs.getDir(project), srcFiles[i]);
|
||||
|
||||
var basedir = file.getParent();
|
||||
var filename = file.getName();
|
||||
var filepath = srcFiles[i].substring(0, srcFiles[i].lastIndexOf(project.getProperty("file.separator")) + 1);
|
||||
|
||||
if (attributes.get("checkuptodate") == "true") {
|
||||
p = "xooki." + file.getAbsolutePath().replace(' ','_') + ".uptodate";
|
||||
upToDate = project.createTask("uptodate");
|
||||
upToDate.setProperty(p);
|
||||
upToDate.setSrcfile(file);
|
||||
upToDate.setTargetFile(new File(attributes.get("destdir") + "/" + filepath + "/" + filename));
|
||||
upToDate.perform();
|
||||
if (project.getProperty(p) != null) {
|
||||
self.log(srcFiles[i]+" is up to date", 3);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
exec = project.createTask("exec");
|
||||
exec.setDir(new File(basedir));
|
||||
exec.setExecutable("jrunscript");
|
||||
exec.setTaskName("generate");
|
||||
exec.createArg().setValue(xookidir + "/xooki2asciidoc.js");
|
||||
exec.createArg().setValue(filename);
|
||||
exec.createArg().setValue(attributes.get("destdir") + "/" + filepath);
|
||||
if (attributes.get("printerfriendly") == "true") {
|
||||
exec.createArg().setValue("print");
|
||||
}
|
||||
exec.perform();
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</scriptdef>
|
||||
</antlib>
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue