generate table of contents for Young Persons guide

This commit is contained in:
walterhiggins 2014-01-04 16:57:43 +00:00
parent 8ff7020c76
commit 6a73144c93
4 changed files with 1253 additions and 9 deletions

View file

@ -61,7 +61,7 @@
<javac includeantruntime="false" srcdir="${src}" destdir="${build}" classpath="${minecraft.dir}/craftbukkit.jar" />
</target>
<target name="gendocs" depends="init" description="Generate API documentation">
<target name="gendocs" depends="construct-ypgpm, init" description="Generate API documentation">
<javac includeantruntime="false" srcdir="src/docs/java"/>
<java classname="jscript" failonerror="true" fork="true" output="docs/API-Reference.md">
<classpath>
@ -72,6 +72,27 @@
</java>
</target>
<target name="gen-toc" depends="init" description="Generate Table of Contents for Young Programmers Guide">
<javac includeantruntime="false" srcdir="src/docs/java"/>
<java classname="jscript" failonerror="true" fork="true" output="${dist}/toc.md">
<classpath>
<pathelement path="src/docs/java"/>
</classpath>
<arg value="src/docs/javascript/generateTOC.js"/>
<arg value="src/docs/templates/ypgpm.mdt"/>
</java>
</target>
<!-- Piece together the Young persons' guide from template and generated table of contents -->
<target name="construct-ypgpm" depends="gen-toc,init">
<concat destfile="docs/YoungPersonsGuideToProgrammingMinecraft.md">
<header filtering="no" trimleading="yes"># The Young Person's Guide to Programming in Minecraft
</header>
<fileset file="${dist}/toc.md" />
<fileset file="src/docs/templates/ypgpm.mdt" />
</concat>
</target>
<target name="zip_js" depends="init">
<delete file="${build}/${js-plugins-dir}.zip"/>

View file

@ -1,7 +1,6 @@
# The Young Person's Guide to Programming in Minecraft
## Table of Contents
* [Introduction](#introduction)
* [Installation](#installation)
* [Learning Javascript](#learning-javascript)
@ -11,14 +10,14 @@
* [Building stuff in Minecraft](#building-stuff-in-minecraft)
* [Common Block Materials](#common-block-materials)
* [Dimensions](#dimensions)
* [More Shapes](#more-shapes)
* [More shapes](#more-shapes)
* [The Drone Object](#the-drone-object)
* [Movement](#movement)
* [Chaining - Combining Building and Movement](#chaining---combining-building-and-movement)
* [Chaining - combining building and movement.](#chaining---combining-building-and-movement)
* [Exercise - Build a simple dwelling](#exercise---build-a-simple-dwelling)
* [Remembering where you started](#remembering-where-you-started)
* [Remembering where you started.](#remembering-where-you-started)
* [Saving your work](#saving-your-work)
* [Your first Minecraft Mod!](#your-first-minecraft-mod)
* [Your First Minecraft Mod!](#your-first-minecraft-mod)
* [Parameters](#parameters)
* [true or false](#true-or-false)
* [More fun with `true` or `false`](#more-fun-with-true-or-false)
@ -31,7 +30,7 @@
* [Putting `for` loops to use - Building a Skyscraper](#putting-for-loops-to-use---building-a-skyscraper)
* [Making Decisions](#making-decisions)
* [Event-Driven programming](#event-driven-programming)
* [Stop listening to events](#stop-listening-to-events)
* [Stop listening to events.](#stop-listening-to-events)
* [Keeping Score - Lookup tables in Javascript](#keeping-score---lookup-tables-in-javascript)
* [Counting block break events for each player](#counting-block-break-events-for-each-player)
* [Next Steps](#next-steps)
@ -1227,5 +1226,3 @@ different objects and methods available for use by ScriptCraft.
[img_ssf]: img/skyscraper_floor.png
[img_ss]: img/skyscraper.png
## Categories
Minecraft, Programming, ScriptCraft

View file

@ -0,0 +1,34 @@
args = args.slice(1);
var template = args[0];
var BufferedReader = java.io.BufferedReader;
var FileReader = java.io.FileReader;
var contents = [], line = undefined;
var br = new BufferedReader( new FileReader(template) );
while ( (line = br.readLine()) != null){
contents.push(line);
}
br.close();
println('## Table of Contents');
for (var i = 0; i < contents.length; i++){
line = contents[i];
if (line.match(/^##\s+/)){
var h2 = line.match(/^##\s+(.*)/)[1].trim();
var link = h2.replace(/[^a-zA-Z0-9 \-]/g,'');
link = link.replace(/ /g,'-');
link = link.toLowerCase();
println (' * [' + h2 + '](#' + link + ')');
}
if (line.match(/^###\s+/)){
var h3 = line.match(/^###\s+(.*)/)[1].trim();
var link = h3.replace(/[^a-zA-Z0-9 \-]/g,'');
var link = link.replace(/ /g,'-');
link = link.toLowerCase();
println (' * [' + h3 + '](#' + link + ')');
}
}

1192
src/docs/templates/ypgpm.mdt vendored Normal file

File diff suppressed because it is too large Load diff