diff --git a/doc/basicopt.txt b/doc/basicopt.txt index 390fc6fd23..a9aa4b8fae 100644 --- a/doc/basicopt.txt +++ b/doc/basicopt.txt @@ -4,7 +4,7 @@ Command: //compile, c compile project with default code generator (C) - //r compile to $nimcache/projname, run with [arguments] + //r compile to $nimcache/projname, run with `arguments` using backend specified by `--backend` (default: c) //doc generate the documentation for inputfile for backend specified by `--backend` (default: c) diff --git a/doc/contributing.md b/doc/contributing.md index 507abdffc8..ba9d4e518e 100644 --- a/doc/contributing.md +++ b/doc/contributing.md @@ -336,7 +336,7 @@ To avoid accidental highlighting follow this rule in ``*.nim`` files: .. Note:: ``*.rst`` files have ``:literal:`` as their default role. So for them the rule above is only applicable if the ``:nim:`` role - is set up manually as the default [*]_:: + is set up manually as the default \[*]:: .. role:: nim(code) :language: nim @@ -345,7 +345,7 @@ To avoid accidental highlighting follow this rule in ``*.nim`` files: The first 2 lines are for other RST implementations, including Github one. - .. [*] this is fulfilled when ``doc/rstcommon.rst`` is included. + \[*] this is fulfilled when ``doc/rstcommon.rst`` is included. Best practices ============== @@ -431,7 +431,7 @@ including prepending location info, writing to log files, etc.). ``` .. _use_Option: -[Ongoing debate] Consider using Option instead of return bool + var argument, +(Ongoing debate) Consider using Option instead of return bool + var argument, unless stack allocation is needed (e.g. for efficiency). ```nim diff --git a/doc/docgen.md b/doc/docgen.md index a651d0a10d..59a99b00f4 100644 --- a/doc/docgen.md +++ b/doc/docgen.md @@ -245,9 +245,9 @@ underscore `_` to a *link text*. Link text is either one word or a group of words enclosed by backticks `\`` (for a one word case backticks are usually omitted). Link text will be displayed *as is* while *link target* will be set to -the anchor [*]_ of Nim symbol that corresponds to link text. +the anchor \[*] of Nim symbol that corresponds to link text. -.. [*] anchors' format is described in `HTML anchor generation`_ section below. +[*] anchors' format is described in `HTML anchor generation`_ section below. If you have a constant: diff --git a/doc/idetools.md b/doc/idetools.md index 21a1b1e342..5bfa594424 100644 --- a/doc/idetools.md +++ b/doc/idetools.md @@ -239,7 +239,7 @@ symbol for which idetools returns valid output. skConst ------- -| **Third column**: module + [n scope nesting] + const name. +| **Third column**: module + \[n scope nesting] + const name. | **Fourth column**: the type of the const value. | **Docstring**: always the empty string. @@ -254,7 +254,7 @@ skConst skEnumField ----------- -| **Third column**: module + [n scope nesting] + enum type + enum field name. +| **Third column**: module + \[n scope nesting] + enum type + enum field name. | **Fourth column**: enum type grouping other enum fields. | **Docstring**: always the empty string. @@ -269,7 +269,7 @@ skEnumField skForVar -------- -| **Third column**: module + [n scope nesting] + var name. +| **Third column**: module + \[n scope nesting] + var name. | **Fourth column**: type of the var. | **Docstring**: always the empty string. @@ -291,7 +291,7 @@ defined, since at that point in the file the parser hasn't processed the full line yet. The signature will be returned complete in posterior instances of the iterator. -| **Third column**: module + [n scope nesting] + iterator name. +| **Third column**: module + \[n scope nesting] + iterator name. | **Fourth column**: signature of the iterator including return type. | **Docstring**: docstring if available. @@ -308,7 +308,7 @@ posterior instances of the iterator. skLabel ------- -| **Third column**: module + [n scope nesting] + name. +| **Third column**: module + \[n scope nesting] + name. | **Fourth column**: always the empty string. | **Docstring**: always the empty string. @@ -325,7 +325,7 @@ skLabel skLet ----- -| **Third column**: module + [n scope nesting] + let name. +| **Third column**: module + \[n scope nesting] + let name. | **Fourth column**: the type of the let variable. | **Docstring**: always the empty string. @@ -346,7 +346,7 @@ defined, since at that point in the file the parser hasn't processed the full line yet. The signature will be returned complete in posterior instances of the macro. -| **Third column**: module + [n scope nesting] + macro name. +| **Third column**: module + \[n scope nesting] + macro name. | **Fourth column**: signature of the macro including return type. | **Docstring**: docstring if available. @@ -384,7 +384,7 @@ Note that at the moment the word `proc` is returned for the signature of the found method instead of the expected `method`. This may change in the future. -| **Third column**: module + [n scope nesting] + method name. +| **Third column**: module + \[n scope nesting] + method name. | **Fourth column**: signature of the method including return type. | **Docstring**: docstring if available. @@ -402,7 +402,7 @@ This may change in the future. skParam ------- -| **Third column**: module + [n scope nesting] + param name. +| **Third column**: module + \[n scope nesting] + param name. | **Fourth column**: the type of the parameter. | **Docstring**: always the empty string. @@ -427,7 +427,7 @@ While at the language level a proc is differentiated from others by the parameters and return value, the signature of the proc returned by idetools returns also the pragmas for the proc. -| **Third column**: module + [n scope nesting] + proc name. +| **Third column**: module + \[n scope nesting] + proc name. | **Fourth column**: signature of the proc including return type. | **Docstring**: docstring if available. @@ -446,7 +446,7 @@ returned by idetools returns also the pragmas for the proc. skResult -------- -| **Third column**: module + [n scope nesting] + result. +| **Third column**: module + \[n scope nesting] + result. | **Fourth column**: the type of the result. | **Docstring**: always the empty string. @@ -467,7 +467,7 @@ defined, since at that point in the file the parser hasn't processed the full line yet. The signature will be returned complete in posterior instances of the template. -| **Third column**: module + [n scope nesting] + template name. +| **Third column**: module + \[n scope nesting] + template name. | **Fourth column**: signature of the template including return type. | **Docstring**: docstring if available. @@ -496,7 +496,7 @@ posterior instances of the template. skType ------ -| **Third column**: module + [n scope nesting] + type name. +| **Third column**: module + \[n scope nesting] + type name. | **Fourth column**: the type. | **Docstring**: always the empty string. @@ -512,7 +512,7 @@ skType skVar ----- -| **Third column**: module + [n scope nesting] + var name. +| **Third column**: module + \[n scope nesting] + var name. | **Fourth column**: the type of the var. | **Docstring**: always the empty string. diff --git a/doc/intern.md b/doc/intern.md index 61b97f85e0..08de0edd6d 100644 --- a/doc/intern.md +++ b/doc/intern.md @@ -328,7 +328,7 @@ Coding Guidelines * Max line length is 100 characters. * Provide spaces around binary operators if that enhances readability. * Use a space after a colon, but not before it. -* [deprecated] Start types with a capital `T`, unless they are +* (deprecated) Start types with a capital `T`, unless they are pointers/references which start with `P`. * Prefer `import package`:nim: over `from package import symbol`:nim:. diff --git a/doc/manual.md b/doc/manual.md index 1cbfe6846c..0be2e9edfb 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -2862,11 +2862,11 @@ ref or pointer type nil procedural type nil sequence `@[]` string `""` -tuple[x: A, y: B, ...] (default(A), default(B), ...) +`tuple[x: A, y: B, ...]` (default(A), default(B), ...) (analogous for objects) -array[0..., T] [default(T), ...] -range[T] default(T); this may be out of the valid range -T = enum cast[T]\(0); this may be an invalid value +`array[0..., T]` `[default(T), ...]` +`range[T]` default(T); this may be out of the valid range +T = enum `cast[T](0)`; this may be an invalid value ============================ ============================================== diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 57764410ec..61b3a7b435 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -182,7 +182,7 @@ template `^^`(n: NimNode, i: untyped): untyped = proc `[]`*[T, U: Ordinal](n: NimNode, x: HSlice[T, U]): seq[NimNode] = ## Slice operation for NimNode. - ## Returns a seq of child of `n` who inclusive range [n[x.a], n[x.b]]. + ## Returns a seq of child of `n` who inclusive range `[n[x.a], n[x.b]]`. let xa = n ^^ x.a let L = (n ^^ x.b) - xa + 1 result = newSeq[NimNode](L) diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim index 87fd34913b..9a98cb9c5b 100644 --- a/lib/impure/db_mysql.nim +++ b/lib/impure/db_mysql.nim @@ -180,7 +180,7 @@ iterator fastRows*(db: DbConn, query: SqlQuery, ## if you require **ALL** the rows. ## ## Breaking the fastRows() iterator during a loop will cause the next - ## database query to raise an [EDb] exception `Commands out of sync`. + ## database query to raise an `EDb` exception `Commands out of sync`. rawExec(db, query, args) var sqlres = mysql.useResult(PMySQL db) if sqlres != nil: @@ -203,7 +203,7 @@ iterator instantRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): InstantRow {.tags: [ReadDbEffect].} = ## Same as fastRows but returns a handle that can be used to get column text - ## on demand using []. Returned handle is valid only within the iterator body. + ## on demand using `[]`. Returned handle is valid only within the iterator body. rawExec(db, query, args) var sqlres = mysql.useResult(PMySQL db) if sqlres != nil: @@ -283,7 +283,7 @@ proc setColumnInfo(columns: var DbColumns; res: PRES; L: int) = iterator instantRows*(db: DbConn; columns: var DbColumns; query: SqlQuery; args: varargs[string, `$`]): InstantRow = ## Same as fastRows but returns a handle that can be used to get column text - ## on demand using []. Returned handle is valid only within the iterator body. + ## on demand using `[]`. Returned handle is valid only within the iterator body. rawExec(db, query, args) var sqlres = mysql.useResult(PMySQL db) if sqlres != nil: diff --git a/lib/impure/db_odbc.nim b/lib/impure/db_odbc.nim index 0ecd8129f1..da1b1e9b59 100644 --- a/lib/impure/db_odbc.nim +++ b/lib/impure/db_odbc.nim @@ -168,7 +168,7 @@ proc dbError*(db: var DbConn) {. raise e proc sqlCheck(db: var DbConn, resVal: TSqlSmallInt) {.raises: [DbError]} = - ## Wrapper that raises [EDb] if `resVal` is neither SQL_SUCCESS or SQL_NO_DATA + ## Wrapper that raises `EDb` if `resVal` is neither SQL_SUCCESS or SQL_NO_DATA if resVal notIn [SQL_SUCCESS, SQL_NO_DATA]: dbError(db) proc sqlGetDBMS(db: var DbConn): string {. @@ -304,7 +304,7 @@ iterator instantRows*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): InstantRow {.tags: [ReadDbEffect, WriteDbEffect].} = ## Same as fastRows but returns a handle that can be used to get column text - ## on demand using []. Returned handle is valid only within the iterator body. + ## on demand using `[]`. Returned handle is valid only within the iterator body. var rowRes: Row = @[] sz: TSqlLen = 0 diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim index 82403ab009..e629b79454 100644 --- a/lib/impure/db_postgres.nim +++ b/lib/impure/db_postgres.nim @@ -271,7 +271,7 @@ iterator instantRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): InstantRow {.tags: [ReadDbEffect].} = ## same as fastRows but returns a handle that can be used to get column text - ## on demand using []. Returned handle is valid only within iterator body. + ## on demand using `[]`. Returned handle is valid only within iterator body. setupSingeRowQuery(db, query, args) fetchinstantRows(db) @@ -279,7 +279,7 @@ iterator instantRows*(db: DbConn, stmtName: SqlPrepared, args: varargs[string, `$`]): InstantRow {.tags: [ReadDbEffect].} = ## same as fastRows but returns a handle that can be used to get column text - ## on demand using []. Returned handle is valid only within iterator body. + ## on demand using `[]`. Returned handle is valid only within iterator body. setupSingeRowQuery(db, stmtName, args) fetchinstantRows(db) diff --git a/lib/packages/docutils/dochelpers.nim b/lib/packages/docutils/dochelpers.nim index a11f2bbbb1..b85e37983c 100644 --- a/lib/packages/docutils/dochelpers.nim +++ b/lib/packages/docutils/dochelpers.nim @@ -82,7 +82,7 @@ proc toLangSymbol*(linkText: PRstNode): LangSymbol = ## ## This proc should be kept in sync with the `renderTypes` proc from ## ``compiler/typesrenderer.nim``. - assert linkText.kind in {rnRef, rnInner} + assert linkText.kind in {rnRstRef, rnInner} const NimDefs = ["proc", "func", "macro", "method", "iterator", "template", "converter", "const", "type", "var", diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index 5d61dc8c3f..8ea2b56f3d 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -24,12 +24,12 @@ ## using simple plaintext representation. ## ## This module is also embedded into Nim compiler; the compiler can output -## the result to HTML [#html]_ or Latex [#latex]_. +## the result to HTML \[#html] or Latex \[#latex]. ## -## .. [#html] commands `nim doc`:cmd: for ``*.nim`` files and +## \[#html] commands `nim doc`:cmd: for ``*.nim`` files and ## `nim rst2html`:cmd: for ``*.rst`` files ## -## .. [#latex] commands `nim doc2tex`:cmd: for ``*.nim`` and +## \[#latex] commands `nim doc2tex`:cmd: for ``*.nim`` and ## `nim rst2tex`:cmd: for ``*.rst``. ## ## If you are new to Markdown/RST please consider reading the following: @@ -84,8 +84,8 @@ ## ## Additional Nim-specific features: ## -## * directives: ``code-block`` [cmp:Sphinx]_, ``title``, -## ``index`` [cmp:Sphinx]_ +## * directives: ``code-block`` \[cmp:Sphinx], ``title``, +## ``index`` \[cmp:Sphinx] ## * predefined roles ## - ``:nim:`` (default), ``:c:`` (C programming language), ## ``:python:``, ``:yaml:``, ``:java:``, ``:cpp:`` (C++), ``:csharp`` (C#). @@ -99,9 +99,9 @@ ## - ``:cmd:`` for commands and common shells syntax ## - ``:console:`` the same for interactive sessions ## (commands should be prepended by ``$``) -## - ``:program:`` for executable names [cmp:Sphinx]_ +## - ``:program:`` for executable names \[cmp:Sphinx] ## (one can just use ``:cmd:`` on single word) -## - ``:option:`` for command line options [cmp:Sphinx]_ +## - ``:option:`` for command line options \[cmp:Sphinx] ## - ``:tok:``, a role for highlighting of programming language tokens ## * ***triple emphasis*** (bold and italic) using \*\*\* ## * ``:idx:`` role for \`interpreted text\` to include the link to this @@ -115,7 +115,7 @@ ## Here the dummy `//` will disappear, while options `compile`:option: ## and `doc`:option: will be left in the final document. ## -## .. [cmp:Sphinx] similar but different from the directives of +## \[cmp:Sphinx] similar but different from the directives of ## Python `Sphinx directives`_ and `Sphinx roles`_ extensions ## ## .. _`extra features`: @@ -1458,7 +1458,7 @@ proc parsePostfix(p: var RstParser, n: PRstNode): PRstNode = newSons = n.sons result = newRstNode(newKind, newSons) else: # some link that will be resolved in `resolveSubs` - newKind = rnRef + newKind = rnRstRef result = newRstNode(newKind, sons=newSons, info=n.info) elif match(p, p.idx, ":w:"): # a role: @@ -1552,7 +1552,7 @@ proc parseWordOrRef(p: var RstParser, father: PRstNode) = while currentTok(p).kind in {tkWord, tkPunct}: if currentTok(p).kind == tkPunct: if isInlineMarkupEnd(p, "_", exact=true): - reference = newRstNode(rnRef, info=lineInfo(p, saveIdx)) + reference = newRstNode(rnRstRef, info=lineInfo(p, saveIdx)) break if not validRefnamePunct(currentTok(p).symbol): break @@ -1746,7 +1746,9 @@ proc parseMarkdownCodeblock(p: var RstParser): PRstNode = defaultCodeLangNim(p, result) proc parseMarkdownLink(p: var RstParser; father: PRstNode): bool = - var desc, link = "" + # Parses Markdown link. If it's Pandoc auto-link then its second + # son (target) will be in tokenized format (rnInner with leafs). + var desc = newRstNode(rnInner) var i = p.idx var parensStack: seq[char] @@ -1754,31 +1756,59 @@ proc parseMarkdownLink(p: var RstParser; father: PRstNode): bool = parensStack.setLen 0 inc i # skip begin token while true: - if p.tok[i].kind in {tkEof, tkIndent}: return false + if p.tok[i].kind == tkEof: return false + if p.tok[i].kind == tkIndent and p.tok[i+1].kind == tkIndent: + return false let isClosing = checkParen(p.tok[i], parensStack) if p.tok[i].symbol == endToken and not isClosing: break - dest.add p.tok[i].symbol + let symbol = if p.tok[i].kind == tkIndent: " " else: p.tok[i].symbol + when dest is string: dest.add symbol + else: dest.add newLeaf(symbol) inc i inc i # skip end token parse("]", desc) - if p.tok[i].symbol != "(": return false - let linkIdx = i + 1 - parse(")", link) - # only commit if we detected no syntax error: - let protocol = safeProtocol(link) - if link == "": - result = false - rstMessage(p, mwBrokenLink, protocol, - p.tok[linkIdx].line, p.tok[linkIdx].col) - else: - let child = newRstNode(rnHyperlink) - child.add desc - child.add link - father.add child + if p.tok[i].symbol == "(": + var link = "" + let linkIdx = i + 1 + parse(")", link) + # only commit if we detected no syntax error: + let protocol = safeProtocol(link) + if link == "": + result = false + rstMessage(p, mwBrokenLink, protocol, + p.tok[linkIdx].line, p.tok[linkIdx].col) + else: + let child = newRstNode(rnHyperlink) + child.add newLeaf(desc.addNodes) + child.add link + father.add child + p.idx = i + result = true + elif roPreferMarkdown in p.s.options: + # Use Pandoc's implicit_header_references extension + var n = newRstNode(rnPandocRef) + if p.tok[i].symbol == "[": + var link = newRstNode(rnInner) + let targetIdx = i + 1 + parse("]", link) + n.add desc + if link.len != 0: # [description][target] + n.add link + n.info = lineInfo(p, targetIdx) + else: # [description=target][] + n.add desc + n.info = lineInfo(p, p.idx + 1) + else: # [description=target] + n.add desc + n.add desc # target is the same as description + n.info = lineInfo(p, p.idx + 1) + father.add n p.idx = i result = true + else: + result = false proc getFootnoteType(label: PRstNode): (FootnoteType, int) = if label.sons.len >= 1 and label.sons[0].kind == rnLeaf and @@ -3510,6 +3540,13 @@ proc preparePass2*(s: PRstSharedState, mainNode: PRstNode) = proc resolveLink(s: PRstSharedState, n: PRstNode) : PRstNode = # Associate this link alias with its target and change node kind to # rnHyperlink or rnInternalRef appropriately. + var desc, alias: PRstNode + if n.kind == rnPandocRef: # link like [desc][alias] + desc = n.sons[0] + alias = n.sons[1] + else: # n.kind == rnRstRef, link like `desc=alias`_ + desc = n + alias = n type LinkDef = object ar: AnchorRule priority: int @@ -3521,14 +3558,13 @@ proc resolveLink(s: PRstSharedState, n: PRstNode) : PRstNode = if result == 0: result = cmp(x.target, y.target) var foundLinks: seq[LinkDef] - let text = newRstNode(rnInner, n.sons) - let refn = rstnodeToRefname(n) + let refn = rstnodeToRefname(alias) var hyperlinks = findRef(s, refn) for y in hyperlinks: foundLinks.add LinkDef(ar: arHyperlink, priority: refPriority(y.kind), target: y.value, info: y.info, tooltip: "(" & $y.kind & ")") - let substRst = findMainAnchorRst(s, text.addNodes, n.info) + let substRst = findMainAnchorRst(s, alias.addNodes, n.info) for subst in substRst: foundLinks.add LinkDef(ar: arInternalRst, priority: subst.priority, target: newLeaf(subst.target.anchor), @@ -3536,19 +3572,19 @@ proc resolveLink(s: PRstSharedState, n: PRstNode) : PRstNode = tooltip: "(" & $subst.anchorType & ")") # find anchors automatically generated from Nim symbols if roNimFile in s.options: - let substNim = findMainAnchorNim(s, signature=text, n.info) + let substNim = findMainAnchorNim(s, signature=alias, n.info) for subst in substNim: foundLinks.add LinkDef(ar: arNim, priority: subst.priority, target: newLeaf(subst.refname), info: subst.info, tooltip: subst.tooltip) foundLinks.sort(cmp = cmp, order = Descending) - let linkText = addNodes(n) + let linkText = addNodes(desc) if foundLinks.len >= 1: let kind = if foundLinks[0].ar == arHyperlink: rnHyperlink elif foundLinks[0].ar == arNim: rnNimdocRef else: rnInternalRef result = newRstNode(kind) - result.sons = @[text, foundLinks[0].target] + result.sons = @[newRstNode(rnInner, desc.sons), foundLinks[0].target] if kind == rnNimdocRef: result.tooltip = foundLinks[0].tooltip if foundLinks.len > 1: # report ambiguous link var targets = newSeq[string]() @@ -3585,7 +3621,7 @@ proc resolveSubs*(s: PRstSharedState, n: PRstNode): PRstNode = if e != "": result = newLeaf(e) else: rstMessage(s.filenames, s.msgHandler, n.info, mwUnknownSubstitution, key) - of rnRef: + of rnRstRef, rnPandocRef: result = resolveLink(s, n) of rnFootnote: var (fnType, num) = getFootnoteType(n.sons[0]) diff --git a/lib/packages/docutils/rstast.nim b/lib/packages/docutils/rstast.nim index eac3a5e15e..05e4ec39e4 100644 --- a/lib/packages/docutils/rstast.nim +++ b/lib/packages/docutils/rstast.nim @@ -49,7 +49,10 @@ type rnCitation, # similar to footnote, so use rnFootnote instead rnFootnoteGroup, # footnote group - exists for a purely stylistic # reason: to display a few footnotes as 1 block - rnStandaloneHyperlink, rnHyperlink, rnRef, rnInternalRef, rnFootnoteRef, + rnStandaloneHyperlink, rnHyperlink, + rnRstRef, # RST reference like `section name`_ + rnPandocRef, # Pandoc Markdown reference like [section name] + rnInternalRef, rnFootnoteRef, rnNimdocRef, # reference to automatically generated Nim symbol rnDirective, # a general directive rnDirArg, # a directive argument (for some directives). @@ -110,7 +113,7 @@ type ## auto-numbered ones without a label) of rnMarkdownBlockQuoteItem: quotationDepth*: int ## number of characters in line prefix - of rnRef, rnSubstitutionReferences, + of rnRstRef, rnPandocRef, rnSubstitutionReferences, rnInterpretedText, rnField, rnInlineCode, rnCodeBlock, rnFootnoteRef: info*: TLineInfo ## To have line/column info for warnings at ## nodes that are post-processed after parsing @@ -281,7 +284,7 @@ proc renderRstToRst(d: var RenderContext, n: PRstNode, result: var string) = inc(d.indent, 2) renderRstSons(d, n, result) dec(d.indent, 2) - of rnRef: + of rnRstRef: result.add("`") renderRstSons(d, n, result) result.add("`_") diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim index 32d2d34836..00f1ac19d9 100644 --- a/lib/packages/docutils/rstgen.nim +++ b/lib/packages/docutils/rstgen.nim @@ -37,7 +37,7 @@ ## ## * The same goes for footnotes/citations links: they point to themselves. ## No backreferences are generated since finding all references of a footnote -## can be done by simply searching for [footnoteName]. +## can be done by simply searching for ``[footnoteName]``. import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils, algorithm, parseutils, std/strbasics @@ -1372,7 +1372,9 @@ proc renderRstToOut(d: PDoc, n: PRstNode, result: var string) = " $1\n\n", "\\item[\\textsuperscript{[$3]}]$2 $1\n", [body, n.anchor.idS, mark, n.anchor]) - of rnRef: + of rnPandocRef: + renderHyperlink(d, text=n.sons[0], link=n.sons[1], result, external=false) + of rnRstRef: renderHyperlink(d, text=n.sons[0], link=n.sons[0], result, external=false) of rnStandaloneHyperlink: renderHyperlink(d, text=n.sons[0], link=n.sons[0], result, external=true) diff --git a/lib/pure/memfiles.nim b/lib/pure/memfiles.nim index f65ca125e1..dacb15e17a 100644 --- a/lib/pure/memfiles.nim +++ b/lib/pure/memfiles.nim @@ -377,7 +377,7 @@ proc `$`*(ms: MemSlice): string {.inline.} = copyMem(addr(result[0]), ms.data, ms.size) iterator memSlices*(mfile: MemFile, delim = '\l', eat = '\r'): MemSlice {.inline.} = - ## Iterates over [optional `eat`] `delim`-delimited slices in MemFile `mfile`. + ## Iterates over \[optional `eat`] `delim`-delimited slices in MemFile `mfile`. ## ## Default parameters parse lines ending in either Unix(\\l) or Windows(\\r\\l) ## style on on a line-by-line basis. I.e., not every line needs the same ending. diff --git a/lib/std/private/schubfach.nim b/lib/std/private/schubfach.nim index 5b965aaa74..206153a689 100644 --- a/lib/std/private/schubfach.nim +++ b/lib/std/private/schubfach.nim @@ -6,7 +6,7 @@ # -------------------------------------------------------------------------------------------------- ## This file contains an implementation of the Schubfach algorithm as described in ## -## [1] Raffaello Giulietti, "The Schubfach way to render doubles", +## \[1] Raffaello Giulietti, "The Schubfach way to render doubles", ## https://drive.google.com/open?id=1luHhyQF9zKlM8yJ1nebU0OgVYhfC6CBN # -------------------------------------------------------------------------------------------------- diff --git a/lib/system/comparisons.nim b/lib/system/comparisons.nim index 7122daa209..daa47fa594 100644 --- a/lib/system/comparisons.nim +++ b/lib/system/comparisons.nim @@ -250,7 +250,7 @@ proc max*[T](x: openArray[T]): T = proc clamp*[T](x, a, b: T): T = - ## Limits the value `x` within the interval [a, b]. + ## Limits the value `x` within the interval \[a, b]. ## This proc is equivalent to but faster than `max(a, min(b, x))`. ## ## .. warning:: `a <= b` is assumed and will not be checked (currently). diff --git a/nimdoc/testproject/expected/subdir/subdir_b/utils.html b/nimdoc/testproject/expected/subdir/subdir_b/utils.html index b3d52c4f5d..d888a4609c 100644 --- a/nimdoc/testproject/expected/subdir/subdir_b/utils.html +++ b/nimdoc/testproject/expected/subdir/subdir_b/utils.html @@ -56,6 +56,9 @@
Ref. type like G and type G and G[T] and type G*[T].
Group ref. with capital letters works: fN11 or fn11
-Ref. [] is the same as proc `[]`(G[T]) because there are no overloads. The full form: proc `[]`*[T](x: G[T]): TRef. []= aka `[]=`(G[T], int, T).Ref. $ aka proc $ or proc `$`.Ref. $(a: ref SomeType).Ref. foo_bar aka iterator foo_bar_.Ref. fn[T; U,V: SomeFloat]().Ref. 'big or func `'big` or `'big`(string). +Ref. [] is the same as proc `[]`(G[T]) because there are no overloads. The full form: proc `[]`*[T](x: G[T]): TRef. []= aka `[]=`(G[T], int, T).Ref. $ aka proc $ or proc `$`.Ref. $(a: ref SomeType).Ref. foo_bar aka iterator foo_bar_.Ref. fn[T; U,V: SomeFloat]().Ref. 'big or func `'big` or `'big`(string). +Now repeat all the auto links of above in Pandoc Markdown Syntax.
+Ref group fn2 or specific function like fn2() or fn2( int ) or fn2(int, float).
+Ref generics like this: binarySearch or binarySearch(openArray[T], K, proc (T, K)) or proc binarySearch(openArray[T], K, proc (T, K)) or in different style: proc binarysearch(openarray[T], K, proc(T, K)). Can be combined with export symbols and type parameters: binarysearch*[T, K](openArray[T], K, proc (T, K)). With spaces binary search.
+Note that proc can be used in postfix form: binarySearch proc.
+Ref. type like G and type G and G[T] and type G*[T].
+Group ref. with capital letters works: fN11 or fn11
+Ref. `[]` is the same as proc `[]`(G[T]) because there are no overloads. The full form: proc `[]`*[T](x: G[T]): T Ref. `[]=` aka `[]=`(G[T], int, T). Ref. $ aka proc $ or proc `$`. Ref. $(a: ref SomeType). Ref. foo_bar aka iterator foo_bar_. Ref. fn[T; U,V: SomeFloat](). Ref. 'big or func `'big` or `'big`(string).
+ +Pandoc Markdown has synax for changing text of links: Ref. this proc or another symbol.
+ +Let us repeat auto links from symbols section below:
+There is also variant f(G[string]). See also f(G[int]).
+