Added @param directive.

This commit is contained in:
Jonathan Bernard 2015-02-05 00:12:51 -06:00
parent caf96db6c4
commit 3609348a94
6 changed files with 38 additions and 15 deletions

View File

@ -1,7 +1,7 @@
#Tue, 13 Aug 2013 08:48:43 -0500 #Fri, 30 May 2014 19:49:05 -0500
name=jlp name=jlp
version=1.7 version=1.8
build.number=25 build.number=6
lib.local=true lib.local=true
release.dir=release release.dir=release
main.class=com.jdblabs.jlp.JLPMain main.class=com.jdblabs.jlp.JLPMain

View File

@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory
*/ */
public class JLPMain { public class JLPMain {
public static final String VERSION = "1.7" public static final String VERSION = "1.8"
private static Logger log = LoggerFactory.getLogger(JLPMain.class) private static Logger log = LoggerFactory.getLogger(JLPMain.class)

View File

@ -40,8 +40,8 @@ public class JLPPegParser extends BaseParser<Object> implements JLPParser {
*/ */
/** /**
* #### Full constructor * #### Full constructor.
* This allows the caller to specific all four of the comment delimiters * This allows the caller to specify all four of the comment delimiters
* recognized by the parser. * recognized by the parser.
*/ */
public JLPPegParser(String mdocStart, String mdocEnd, public JLPPegParser(String mdocStart, String mdocEnd,
@ -52,6 +52,20 @@ public class JLPPegParser extends BaseParser<Object> implements JLPParser {
SDOC_START = String(sdocStart).label("SDOC_START"); SDOC_START = String(sdocStart).label("SDOC_START");
MDOC_LINE_START = AnyOf(mdocLineStart).label("MDOC_LINE_START"); } MDOC_LINE_START = AnyOf(mdocLineStart).label("MDOC_LINE_START"); }
/**
* #### Full constructor supporting multiple comment types.
* This allows the caller to specify all four of the comment delimiters
* recognized by the parser, supplying multiple types of comment
* delimiters.
*/
public JLPPegParser(List mdocStarts, List mdocEnds,
String mdocLineStarts, List sdocStart) {
MDOC_START = FirstOf(mdocStarts.toArray()).label("MDOC_START");
MDOC_END = FirstOf(mdocEnds.toArray()).label("MDOC_END");
SDOC_START = FirstOf(sdocStarts.toArray()).label("SDOC_START");
MDOC_LINE_START = AnyOf(mdocLineStart).label("MDOC_LINE_START"); }
/** /**
* #### Single-line comments only constructor. * #### Single-line comments only constructor.
* This allows the caller to easily set up the parser to only recognize * This allows the caller to easily set up the parser to only recognize
@ -292,7 +306,7 @@ public class JLPPegParser extends BaseParser<Object> implements JLPParser {
* Parses the rule: * Parses the rule:
* *
* SLongDirective = * SLongDirective =
* (API_DIR / EXAMPLE_DIR) RemainingSDocLine SDocText? * (API_DIR / EXAMPLE_DIR / PARAM_DIR) RemainingSDocLine SDocText?
* *
* Pushes a [`Directive`] node onto the stack. * Pushes a [`Directive`] node onto the stack.
* *
@ -302,8 +316,8 @@ public class JLPPegParser extends BaseParser<Object> implements JLPParser {
return Sequence( return Sequence(
push(curLineNum), push(curLineNum),
FirstOf(API_DIR, EXAMPLE_DIR), push(match()), FirstOf(API_DIR, EXAMPLE_DIR, PARAM_DIR), push(match()),
RemainingSDocLine(), push(match()), RemainingSDocLine(), push(match()),
Optional(Sequence( Optional(Sequence(
SDocText(), SDocText(),
@ -318,7 +332,7 @@ public class JLPPegParser extends BaseParser<Object> implements JLPParser {
* Parses the rule: * Parses the rule:
* *
* MLongDirective = * MLongDirective =
* (API_DIR / EXAMPLE_DIR) RemainingMDocLine MDocText? * (API_DIR / EXAMPLE_DIR / PARAM_DIR) RemainingMDocLine MDocText?
* *
* Pushes a [`Directive`] node onto the stack. * Pushes a [`Directive`] node onto the stack.
* *
@ -328,8 +342,8 @@ public class JLPPegParser extends BaseParser<Object> implements JLPParser {
return Sequence( return Sequence(
push(curLineNum), push(curLineNum),
FirstOf(API_DIR, EXAMPLE_DIR), push(match()), FirstOf(API_DIR, EXAMPLE_DIR, PARAM_DIR), push(match()),
RemainingMDocLine(), push(match()), RemainingMDocLine(), push(match()),
Optional(Sequence( Optional(Sequence(
MDocText(), MDocText(),
@ -497,6 +511,7 @@ public class JLPPegParser extends BaseParser<Object> implements JLPParser {
Rule EXAMPLE_DIR = IgnoreCase("example"); Rule EXAMPLE_DIR = IgnoreCase("example");
Rule INCLUDE_DIR = IgnoreCase("include"); Rule INCLUDE_DIR = IgnoreCase("include");
Rule ORG_DIR = IgnoreCase("org"); Rule ORG_DIR = IgnoreCase("org");
Rule PARAM_DIR = IgnoreCase("param");
/// #### Hard-coded terminals. /// #### Hard-coded terminals.
Rule AT = Ch('@').label("AT"); Rule AT = Ch('@').label("AT");

View File

@ -281,6 +281,9 @@ public class LiterateMarkdownGenerator extends JLPBaseGenerator {
case DirectiveType.Example: case DirectiveType.Example:
return directive.value return directive.value
case DirectiveType.Param:
return "" // TODO: can we do better here, even though we're
// not understanding the source yet?
// TODO: // TODO:
// case DirectiveType.Include: // case DirectiveType.Include:

View File

@ -438,8 +438,8 @@ public class Processor {
break break
case 'html': case 'xml': case 'html': case 'xml':
parsers[sourceType] = Parboiled.createParser( parsers[sourceType] = Parboiled.createParser(
JLPPegParser, '<!--', '-->', JLPPegParser, '<!--!', '-->',
'#$%^&*()_-+=|;:\'",<>?~`', '<<?') '!#$%^&*()_-+=|;:\'",<>?~`', '<<?')
break break
case 'sql': case 'sql':
parsers[sourceType] = Parboiled.createParser(JLPPegParser, parsers[sourceType] = Parboiled.createParser(JLPPegParser,

View File

@ -50,10 +50,15 @@ public class Directive extends ASTNode {
* the [`LinkAnchor`] documentation for more information about link * the [`LinkAnchor`] documentation for more information about link
* anchors. * anchors.
* *
* Param
* : Used to document a parameter to a function, method, or subroutine.
* This is typically used in API documentation, but no generator
* currently knows how to do anything intelligent with this directive.
*
* [`LinkAnchor`]: jlp://jlp.jdb-labs.com/LinkAnchor * [`LinkAnchor`]: jlp://jlp.jdb-labs.com/LinkAnchor
*/ */
public static enum DirectiveType { public static enum DirectiveType {
Api, Author, Copyright, Example, Include, Org; Api, Author, Copyright, Example, Include, Org, Param;
public static DirectiveType parse(String typeString) { public static DirectiveType parse(String typeString) {
valueOf(typeString.toLowerCase().capitalize()) } } valueOf(typeString.toLowerCase().capitalize()) } }