$moduledesc
- $content -diff --git a/compiler/commands.nim b/compiler/commands.nim index 0a045c2918..6cce04404a 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -491,6 +491,7 @@ proc parseCommand*(command: string): Command = of "e": cmdNimscript of "doc0": cmdDoc0 of "doc2", "doc": cmdDoc + of "book": cmdBook of "doc2tex": cmdDoc2tex of "rst2html": cmdRst2html of "md2tex": cmdMd2tex diff --git a/compiler/docgen.nim b/compiler/docgen.nim index e009d06f22..5d082c3a70 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -24,7 +24,7 @@ import import packages/docutils/rstast except FileIndex, TLineInfo import std/[os, strutils, strtabs, algorithm, json, osproc, tables, intsets, xmltree, sequtils] -from std/uri import encodeUrl +from std/uri import encodeUrl, parseUri, isAbsolute from nodejs import findNodeJs when defined(nimPreviewSlimSystem): @@ -76,6 +76,19 @@ type json: JsonNode rst: PRstNode rstField: string + NavItemKind = enum + niLink + niLabel + niHeading + NavItem = object + ## Navigation entry for the sidebar navigation. + title: string + case kind: NavItemKind + of niLink: + dest: string + else: + discard + sons: seq[NavItem] TDocumentor = object of rstgen.RstGenerator modDescPre: ItemPre # module description, not finalized modDescFinal: string # module description, after RST pass 2 and rendering @@ -1726,10 +1739,19 @@ proc genOutFile(d: PDoc, groupedToc = false): string = dispA(d.conf, subtitle, "
$moduledesc
- $content -This is a test project for nim book.
+ +Inline code snippet:
+proc twice*(a: int): int = + a * 2+
This snippet is tested during documentation build:
+proc twice*(a: int): int = + a * 2 + +assert 10.twice == 20+
The same but using .. code:: directive:
+proc twice*(a: int): int = + a * 2
proc twice*(a: int): int = + a * 2 + +assert 10.twice == 20
Code included from a source file:
+proc double*(x: int): int = + x * 2 +
Selective inclusuion:
++proc double*(x: int): int = + x * 2 +
Doesn't have to be Nim code:
+# This is Python +def double(x: int) -> int: + return x * 2 ++
It's dangerous to go alone!
+Take this!
+echo "Indeed"
This is a link to a heading on the same page: Code.
+This is a link to a heading on another page: intro.md: Heading.
+Same, but with different syntax: intro.md: Heading.
+You can use standard Markdown syntax, too: I am a link
+ + ++