Documentation fixes.

* Some typo fixes in code
 * nim documentation now generates API doc with source links
 * presenter now uses "" if a string starts with @ or `
 * Removed some outdated stuff
This commit is contained in:
Felix Krause 2016-01-24 19:15:50 +01:00
parent a08f4c1e4e
commit b7828884bd
5 changed files with 38 additions and 39 deletions

View File

@ -8,11 +8,6 @@ task tests, "Run all tests":
--verbosity:0 --verbosity:0
setCommand "c", "test/tests" setCommand "c", "test/tests"
task lexerTests, "Run lexer tests":
--r
--verbosity:0
setCommand "c", "test/lexing"
task parserTests, "Run parser tests": task parserTests, "Run parser tests":
--r --r
--verbosity:0 --verbosity:0
@ -25,8 +20,8 @@ task serializationTests, "Run serialization tests":
task documentation, "Generate documentation": task documentation, "Generate documentation":
exec "mkdir -p docout" exec "mkdir -p docout"
exec r"nim doc2 -o:docout/yaml.html yaml" exec r"nim doc2 -o:docout/yaml.html --docSeeSrcUrl:https://github.com/flyx/NimYAML/blob/`git log -n 1 --format=%H` yaml"
exec r"nim doc2 -o:docout/serialization.html yaml/serialization.nim" exec r"nim doc2 -o:docout/serialization.html --docSeeSrcUrl:https://github.com/flyx/NimYAML/blob/`git log -n 1 --format=%H` yaml/serialization.nim"
exec r"nim rst2html -o:docout/index.html doc/index.txt" exec r"nim rst2html -o:docout/index.html doc/index.txt"
exec "cp doc/docutils.css doc/style.css doc/testing.html docout" exec "cp doc/docutils.css doc/style.css doc/testing.html docout"
setCommand "nop" setCommand "nop"

View File

@ -66,6 +66,15 @@ html {
background-color: rgba(252, 248, 244, 0.75); background-color: rgba(252, 248, 244, 0.75);
} }
/* necessary for links to scroll to the right position */
dt:before {
margin-top: -50px;
height: 50px;
content: ' ';
display: block;
visibility: hidden;
}
#testingground textarea { #testingground textarea {
width: 100%; width: 100%;
height: 100%; height: 100%;

View File

@ -136,7 +136,7 @@ template handleObjectStart(k: YamlStreamEventKind) {.dirty.} =
debug("started sequence at " & (if level.indentation == -1: $indentation else: debug("started sequence at " & (if level.indentation == -1: $indentation else:
$level.indentation)) $level.indentation))
level.kind = fplSequence level.kind = fplSequence
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
if level.indentation == -1: if level.indentation == -1:
level.indentation = indentation level.indentation = indentation
@ -183,7 +183,7 @@ template handleMapKeyIndicator() {.dirty.} =
of fplMapValue: of fplMapValue:
if level.indentation != indentation: if level.indentation != indentation:
parserError("Invalid indentation of map key indicator") parserError("Invalid indentation of map key indicator")
yield scalarEvent("", yTagQuestionmark, yAnchorNone) yield scalarEvent("", yTagQuestionMark, yAnchorNone)
level.kind = fplMapKey level.kind = fplMapKey
ancestry.add(level) ancestry.add(level)
level = FastParseLevel(kind: fplUnknown, indentation: -1) level = FastParseLevel(kind: fplUnknown, indentation: -1)
@ -205,16 +205,16 @@ template handleMapValueIndicator() {.dirty.} =
of fplUnknown: of fplUnknown:
if level.indentation == -1: if level.indentation == -1:
handleObjectStart(yamlStartMap) handleObjectStart(yamlStartMap)
yield scalarEvent("", yTagQuestionmark, yAnchorNone) yield scalarEvent("", yTagQuestionMark, yAnchorNone)
else: else:
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
ancestry[ancestry.high].kind = fplMapValue ancestry[ancestry.high].kind = fplMapValue
of fplMapKey: of fplMapKey:
if level.indentation != indentation: if level.indentation != indentation:
parserError("Invalid indentation of map key indicator") parserError("Invalid indentation of map key indicator")
yield scalarEvent("", yTagQuestionmark, yAnchorNone) yield scalarEvent("", yTagQuestionMark, yAnchorNone)
level.kind = fplMapValue level.kind = fplMapValue
ancestry.add(level) ancestry.add(level)
level = FastParseLevel(kind: fplUnknown, indentation: -1) level = FastParseLevel(kind: fplUnknown, indentation: -1)
@ -238,14 +238,14 @@ template initDocValues() {.dirty.} =
shorthands["!!"] = "tag:yaml.org,2002:" shorthands["!!"] = "tag:yaml.org,2002:"
nextAnchorId = 0.AnchorId nextAnchorId = 0.AnchorId
level = FastParseLevel(kind: fplUnknown, indentation: -1) level = FastParseLevel(kind: fplUnknown, indentation: -1)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
template handleTagHandle() {.dirty.} = template handleTagHandle() {.dirty.} =
startToken() startToken()
if level.kind != fplUnknown: if level.kind != fplUnknown:
parserError("Unexpected tag handle") parserError("Unexpected tag handle")
if tag != yTagQuestionmark: if tag != yTagQuestionMark:
parserError("Only one tag handle is allowed per node") parserError("Only one tag handle is allowed per node")
content = "" content = ""
var var
@ -281,7 +281,7 @@ template handleAlias() {.dirty.} =
startToken() startToken()
if level.kind != fplUnknown: if level.kind != fplUnknown:
parserError("Unexpected token") parserError("Unexpected token")
if anchor != yAnchorNone or tag != yTagQuestionmark: if anchor != yAnchorNone or tag != yTagQuestionMark:
parserError("Alias may not have anchor or tag") parserError("Alias may not have anchor or tag")
content = "" content = ""
p.lexer.anchorName(content) p.lexer.anchorName(content)
@ -338,7 +338,7 @@ template handleBlockItemStart() {.dirty.} =
level = FastParseLevel(kind: fplUnknown, indentation: indentation) level = FastParseLevel(kind: fplUnknown, indentation: indentation)
of fplMapValue: of fplMapValue:
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
level.kind = fplMapKey level.kind = fplMapKey
ancestry.add(level) ancestry.add(level)
@ -1313,8 +1313,8 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
var stateAfter: FastParseState var stateAfter: FastParseState
content = "" content = ""
p.lexer.blockScalar(content, stateAfter) p.lexer.blockScalar(content, stateAfter)
if tag == yTagQuestionmark: if tag == yTagQuestionMark:
tag = yTagExclamationmark tag = yTagExclamationMark
yield scalarEvent(content, tag, anchor) yield scalarEvent(content, tag, anchor)
handleObjectEnd(stateAfter) handleObjectEnd(stateAfter)
of '-': of '-':
@ -1424,14 +1424,14 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
case level.kind case level.kind
of fplMapValue: of fplMapValue:
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
level.kind = fplMapKey level.kind = fplMapKey
of fplMapKey: of fplMapKey:
if tag != yTagQuestionmark or anchor != yAnchorNone or if tag != yTagQuestionMark or anchor != yAnchorNone or
explicitFlowKey: explicitFlowKey:
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
of fplSequence: of fplSequence:
@ -1446,9 +1446,9 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
level = ancestry.pop() level = ancestry.pop()
case level.kind case level.kind
of fplSequence: of fplSequence:
if tag != yTagQuestionmark or anchor != yAnchorNone: if tag != yTagQuestionMark or anchor != yAnchorNone:
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
of fplMapKey, fplMapValue: of fplMapKey, fplMapValue:
startToken() startToken()
@ -1463,17 +1463,17 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
case level.kind case level.kind
of fplSequence: of fplSequence:
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
of fplMapValue: of fplMapValue:
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
level.kind = fplMapKey level.kind = fplMapKey
explicitFlowKey = false explicitFlowKey = false
of fplMapKey: of fplMapKey:
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
explicitFlowKey = false explicitFlowKey = false
@ -1492,7 +1492,7 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
parserError("Unexpected token (expected ',')") parserError("Unexpected token (expected ',')")
of fplMapKey: of fplMapKey:
yield scalarEvent("", tag, anchor) yield scalarEvent("", tag, anchor)
tag = yTagQuestionmark tag = yTagQuestionMark
anchor = yAnchorNone anchor = yAnchorNone
level.kind = fplMapValue level.kind = fplMapValue
of fplUnknown, fplScalar: of fplUnknown, fplScalar:
@ -1514,8 +1514,8 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
content = "" content = ""
startToken() startToken()
p.lexer.doubleQuotedScalar(content) p.lexer.doubleQuotedScalar(content)
if tag == yTagQuestionmark: if tag == yTagQuestionMark:
tag = yTagExclamationmark tag = yTagExclamationMark
yield scalarEvent(content, tag, anchor) yield scalarEvent(content, tag, anchor)
handleObjectEnd(fpFlowAfterObject) handleObjectEnd(fpFlowAfterObject)
of '!': of '!':
@ -1567,7 +1567,7 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
of fplSequence: of fplSequence:
discard discard
of fplMapValue: of fplMapValue:
yield scalarEvent("", yTagQuestionmark, yAnchorNone) yield scalarEvent("", yTagQuestionMark, yAnchorNone)
level.kind = fplMapKey level.kind = fplMapKey
explicitFlowKey = false explicitFlowKey = false
of fplMapKey: of fplMapKey:

View File

@ -12,7 +12,7 @@ type
dFlowSequenceStart dFlowSequenceStart
proc needsEscaping(scalar: string): bool {.raises: [].} = proc needsEscaping(scalar: string): bool {.raises: [].} =
scalar.len == 0 or scalar.len == 0 or scalar[0] in ['@', '`'] or
scalar.find({'{', '}', '[', ']', ',', '#', '-', ':', '?', '%', '"', scalar.find({'{', '}', '[', ']', ',', '#', '-', ':', '?', '%', '"',
'\'', '\x0A', '\c'}) != -1 '\'', '\x0A', '\c'}) != -1

View File

@ -27,7 +27,7 @@ type
TypeHint* = enum TypeHint* = enum
## A type hint can be computed from scalar content and tells you what ## A type hint can be computed from scalar content and tells you what
## NimYAML thinks the scalar's type is. It is generated by ## NimYAML thinks the scalar's type is. It is generated by
## `guessType <#guessType,string,TypeHint>`_ The first matching RegEx ## `guessType <#guessType,string>`_ The first matching RegEx
## in the following table will be the type hint of a scalar string. ## in the following table will be the type hint of a scalar string.
## ##
## You can use it to determine the type of YAML scalars that have a '?' ## You can use it to determine the type of YAML scalars that have a '?'
@ -118,14 +118,9 @@ type
TagLibrary* = ref object TagLibrary* = ref object
## A ``TagLibrary`` maps tag URIs to ``TagId`` s. ## A ``TagLibrary`` maps tag URIs to ``TagId`` s.
## ##
## Three tag libraries are provided with this module:
## `failsafeTagLibrary <#failsafeTagLibrary>`_,
## `coreTagLibrary <#coreTagLibrary>`_, and
## `extendedTagLibrary <#extendedTagLibrary>`_.
##
## When `YamlParser <#YamlParser>`_ encounters tags not existing in the ## When `YamlParser <#YamlParser>`_ encounters tags not existing in the
## tag library, it will use ## tag library, it will use
## `registerTagUri <#registerTagUri,TagLibrary,string,TagId>`_ to add ## `registerTagUri <#registerTagUri,TagLibrary,string>`_ to add
## the tag to the library. ## the tag to the library.
## ##
## You can base your tag library on common tag libraries by initializing ## You can base your tag library on common tag libraries by initializing
@ -148,7 +143,7 @@ type
YamlParser* = ref object YamlParser* = ref object
## A parser object. Retains its ``TagLibrary`` across calls to ## A parser object. Retains its ``TagLibrary`` across calls to
## `parse <#parse,YamlParser,Stream,YamlStream>`_. Can be used ## `parse <#parse,YamlParser,Stream>`_. Can be used
## to access anchor names while parsing a YAML character stream, but ## to access anchor names while parsing a YAML character stream, but
## only until the document goes out of scope (i.e. until ## only until the document goes out of scope (i.e. until
## ``yamlEndDocument`` is yielded). ## ``yamlEndDocument`` is yielded).