From 6bc32358028837ceff5c4700a62d29efa466839d Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Tue, 10 Jan 2012 10:11:35 -0600 Subject: [PATCH] Changed docId algorithm. * Updated documentation to add manual titles. * Reworked the way `docIds` are chosen. Now instead of the full relative path name we use just the file, or enough of the relative pathname to uniquely identify the file. --- README.md | 12 +++++---- project.properties | 6 ++--- .../com/jdblabs/jlp/JLPBaseGenerator.groovy | 3 ++- src/main/com/jdblabs/jlp/JLPMain.groovy | 7 ++--- src/main/com/jdblabs/jlp/JLPParser.java | 3 ++- src/main/com/jdblabs/jlp/JLPPegParser.java | 10 ++++--- src/main/com/jdblabs/jlp/LinkAnchor.groovy | 3 ++- .../jlp/LiterateMarkdownGenerator.groovy | 3 ++- .../com/jdblabs/jlp/MarkdownParser.groovy | 3 ++- src/main/com/jdblabs/jlp/Processor.groovy | 26 ++++++++++++++++--- src/main/com/jdblabs/jlp/TargetDoc.groovy | 3 ++- src/main/com/jdblabs/jlp/ast/ASTNode.groovy | 3 ++- src/main/com/jdblabs/jlp/ast/Block.groovy | 3 ++- src/main/com/jdblabs/jlp/ast/CodeBlock.groovy | 3 ++- src/main/com/jdblabs/jlp/ast/Directive.groovy | 3 ++- src/main/com/jdblabs/jlp/ast/DocBlock.groovy | 3 ++- src/main/com/jdblabs/jlp/ast/DocText.groovy | 3 ++- .../com/jdblabs/jlp/ast/SourceFile.groovy | 5 ++-- 18 files changed, 69 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index bd0ed86..c75f16e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Overview +# J Literate Programming + +## Overview *Jonathan's Literate Programming* is my take on literate programming. This project grew out of a desire for a documentation system that: @@ -53,9 +55,9 @@ This project is in its infancy and some of the larger goals are still unmet: JLP processing directives would allow the author to specify which is intended on a file (or block?) level. -# Project Architecture +## Project Architecture -## Control and Flow +### Control and Flow * [JLPMain](jlp://jlp.jdb-labs.com/JLPMain) @@ -85,7 +87,7 @@ This project is in its infancy and some of the larger goals are still unmet: [Markdown]: http://daringfireball.net/projects/markdown/ -## Parsing +### Parsing * [JLPParser](jlp://jlp.jdb-labs.com/JLPParser) @@ -101,7 +103,7 @@ This project is in its infancy and some of the larger goals are still unmet: [PEG parser]: http://en.wikipedia.org/wiki/Parsing_expression_grammar [parboiled]: http://www.parboiled.org -## Abstract Syntax Tree +### Abstract Syntax Tree * [SourceFile](jlp://jlp.jdb-labs.com/ast/SourceFile) diff --git a/project.properties b/project.properties index 763b9d8..f9970fe 100644 --- a/project.properties +++ b/project.properties @@ -1,7 +1,7 @@ -#Fri, 06 Jan 2012 12:20:57 -0600 +#Tue, 10 Jan 2012 10:00:20 -0600 name=jlp -version=1.5 -build.number=6 +version=1.6 +build.number=5 lib.local=true release.dir=release main.class=com.jdblabs.jlp.JLPMain diff --git a/src/main/com/jdblabs/jlp/JLPBaseGenerator.groovy b/src/main/com/jdblabs/jlp/JLPBaseGenerator.groovy index 31b24f9..e766ccb 100644 --- a/src/main/com/jdblabs/jlp/JLPBaseGenerator.groovy +++ b/src/main/com/jdblabs/jlp/JLPBaseGenerator.groovy @@ -1,6 +1,7 @@ /** + * # JLPBaseGenerator * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp diff --git a/src/main/com/jdblabs/jlp/JLPMain.groovy b/src/main/com/jdblabs/jlp/JLPMain.groovy index 285b496..90e5a61 100644 --- a/src/main/com/jdblabs/jlp/JLPMain.groovy +++ b/src/main/com/jdblabs/jlp/JLPMain.groovy @@ -1,6 +1,7 @@ /** - * @author Jonathan Bernard - * @copyright JDB Labs 2010-2011 + * # JLPMain + * @author Jonathan Bernard (jdb@jdb-labs.com) + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp @@ -18,7 +19,7 @@ import org.slf4j.LoggerFactory */ public class JLPMain { - public static final String VERSION = "1.5" + public static final String VERSION = "1.6" private static Logger log = LoggerFactory.getLogger(JLPMain.class) diff --git a/src/main/com/jdblabs/jlp/JLPParser.java b/src/main/com/jdblabs/jlp/JLPParser.java index 7bf46a9..5a18ca7 100644 --- a/src/main/com/jdblabs/jlp/JLPParser.java +++ b/src/main/com/jdblabs/jlp/JLPParser.java @@ -1,6 +1,7 @@ /** + * # JLPParser * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp; diff --git a/src/main/com/jdblabs/jlp/JLPPegParser.java b/src/main/com/jdblabs/jlp/JLPPegParser.java index 0fe3145..86292a1 100644 --- a/src/main/com/jdblabs/jlp/JLPPegParser.java +++ b/src/main/com/jdblabs/jlp/JLPPegParser.java @@ -1,3 +1,9 @@ +/** + * # JLPPegParser + * @author Jonathan Bernard (jdb@jdb-labs.com) + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) + * @org jlp.jdb-labs.com/JLPPegParser + */ package com.jdblabs.jlp; import com.jdblabs.jlp.ast.*; @@ -10,10 +16,6 @@ import org.parboiled.Rule; import org.parboiled.annotations.*; import org.parboiled.parserunners.ReportingParseRunner; -/** - * - * @org jlp.jdb-labs.com/JLPPegParser - */ @BuildParseTree public class JLPPegParser extends BaseParser implements JLPParser { diff --git a/src/main/com/jdblabs/jlp/LinkAnchor.groovy b/src/main/com/jdblabs/jlp/LinkAnchor.groovy index bf111ae..7b294f1 100644 --- a/src/main/com/jdblabs/jlp/LinkAnchor.groovy +++ b/src/main/com/jdblabs/jlp/LinkAnchor.groovy @@ -1,6 +1,7 @@ /** + * # LinkAnchor * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp diff --git a/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy b/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy index e629884..9677a22 100644 --- a/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy +++ b/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy @@ -1,6 +1,7 @@ /** + * # LiterateMarkdownGenerator * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp diff --git a/src/main/com/jdblabs/jlp/MarkdownParser.groovy b/src/main/com/jdblabs/jlp/MarkdownParser.groovy index b957491..b89928d 100644 --- a/src/main/com/jdblabs/jlp/MarkdownParser.groovy +++ b/src/main/com/jdblabs/jlp/MarkdownParser.groovy @@ -1,6 +1,7 @@ /** + * # MarkdownParser * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp diff --git a/src/main/com/jdblabs/jlp/Processor.groovy b/src/main/com/jdblabs/jlp/Processor.groovy index d47194c..40e0e6b 100644 --- a/src/main/com/jdblabs/jlp/Processor.groovy +++ b/src/main/com/jdblabs/jlp/Processor.groovy @@ -1,6 +1,7 @@ /** - * @author Jonathan Bernard - * @copyright JDB Labs 2010-2011 + * # Processor + * @author Jonathan Bernard (jdb@jdb-labs.com) + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp @@ -108,9 +109,26 @@ public class Processor { shFile.delete() /// * Create the processing context for each input file. We are using - /// the relative path of the file as the document id. + /// the name of the file (including the extension) as the id. If there + /// is more than one file with the same name we will include the + /// file's parent directory as well. inputFiles.each { file -> - def docId = getRelativeFilepath(inputRoot, file) + + // Get the relative path as path elements. + def relPath = getRelativeFilepath(inputRoot, file) + def pathParts = relPath.split('/') as List + + // Start with just the file name. + def docId = pathParts.pop() + + log.trace("New target document: '{}' from source: '{}'", + docId, relPath) + + // As long as the current id is taken, add the next parent directory + // to the id. + while(docs[docId] != null) { docId = pathParts.pop() + '/' + docId } + + // Finally create the TargetDoc item. docs[docId] = new TargetDoc( sourceDocId: docId, sourceFile: file, diff --git a/src/main/com/jdblabs/jlp/TargetDoc.groovy b/src/main/com/jdblabs/jlp/TargetDoc.groovy index 8e28fb8..c5c275a 100644 --- a/src/main/com/jdblabs/jlp/TargetDoc.groovy +++ b/src/main/com/jdblabs/jlp/TargetDoc.groovy @@ -1,6 +1,7 @@ /** + * # TargetDoc * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp diff --git a/src/main/com/jdblabs/jlp/ast/ASTNode.groovy b/src/main/com/jdblabs/jlp/ast/ASTNode.groovy index 6622177..064132b 100644 --- a/src/main/com/jdblabs/jlp/ast/ASTNode.groovy +++ b/src/main/com/jdblabs/jlp/ast/ASTNode.groovy @@ -1,6 +1,7 @@ /** + * # ASTNode * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp.ast diff --git a/src/main/com/jdblabs/jlp/ast/Block.groovy b/src/main/com/jdblabs/jlp/ast/Block.groovy index 486bb23..0564bc7 100644 --- a/src/main/com/jdblabs/jlp/ast/Block.groovy +++ b/src/main/com/jdblabs/jlp/ast/Block.groovy @@ -1,6 +1,7 @@ /** + * # Block * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp.ast diff --git a/src/main/com/jdblabs/jlp/ast/CodeBlock.groovy b/src/main/com/jdblabs/jlp/ast/CodeBlock.groovy index 2ed22fc..f21752c 100644 --- a/src/main/com/jdblabs/jlp/ast/CodeBlock.groovy +++ b/src/main/com/jdblabs/jlp/ast/CodeBlock.groovy @@ -1,6 +1,7 @@ /** + * # CodeBlock * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) * @org jlp.jdb-labs.com/ast/CodeBlock */ package com.jdblabs.jlp.ast diff --git a/src/main/com/jdblabs/jlp/ast/Directive.groovy b/src/main/com/jdblabs/jlp/ast/Directive.groovy index f540cf9..b6a2518 100644 --- a/src/main/com/jdblabs/jlp/ast/Directive.groovy +++ b/src/main/com/jdblabs/jlp/ast/Directive.groovy @@ -1,6 +1,7 @@ /** + * # Directive * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp.ast diff --git a/src/main/com/jdblabs/jlp/ast/DocBlock.groovy b/src/main/com/jdblabs/jlp/ast/DocBlock.groovy index c5cd149..afce65b 100644 --- a/src/main/com/jdblabs/jlp/ast/DocBlock.groovy +++ b/src/main/com/jdblabs/jlp/ast/DocBlock.groovy @@ -1,6 +1,7 @@ /** + * # DocBlock * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp.ast diff --git a/src/main/com/jdblabs/jlp/ast/DocText.groovy b/src/main/com/jdblabs/jlp/ast/DocText.groovy index d327a2f..90c1f0d 100644 --- a/src/main/com/jdblabs/jlp/ast/DocText.groovy +++ b/src/main/com/jdblabs/jlp/ast/DocText.groovy @@ -1,6 +1,7 @@ /** + * # DocText * @author Jonathan Bernard (jdb@jdb-labs.com) - * @copyright JDB Labs 2010-2011 + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp.ast diff --git a/src/main/com/jdblabs/jlp/ast/SourceFile.groovy b/src/main/com/jdblabs/jlp/ast/SourceFile.groovy index 67804f5..914bc9f 100644 --- a/src/main/com/jdblabs/jlp/ast/SourceFile.groovy +++ b/src/main/com/jdblabs/jlp/ast/SourceFile.groovy @@ -1,6 +1,7 @@ /** - * @author Jonathan Bernard - * @copyright JDB Labs 2010-2011 + * # SourceFile + * @author Jonathan Bernard (jdb@jdb-labs.com) + * @copyright 2011-2012 [JDB Labs LLC](http://jdb-labs.com) */ package com.jdblabs.jlp.ast