From 1a88c01f92b07f0311258ee832863a6d2b7c6991 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 30 May 2016 20:26:39 +0200 Subject: [PATCH] documentation build cleaned up --- doc/manual/exceptions.txt | 2 +- doc/manual/lexing.txt | 2 +- doc/manual/syntax.txt | 2 +- doc/manual/types.txt | 2 +- doc/niminst.txt | 4 ++-- lib/core/macros.nim | 2 +- lib/impure/re.nim | 2 +- lib/pure/net.nim | 23 +++++++++++++---------- lib/pure/parsecfg.nim | 26 +++++++++++++------------- lib/pure/parsexml.nim | 4 ++-- lib/pure/pegs.nim | 2 +- lib/pure/random.nim | 8 +++++--- lib/pure/subexes.nim | 2 +- 13 files changed, 43 insertions(+), 38 deletions(-) diff --git a/doc/manual/exceptions.txt b/doc/manual/exceptions.txt index e7af653863..d06c13df48 100644 --- a/doc/manual/exceptions.txt +++ b/doc/manual/exceptions.txt @@ -155,4 +155,4 @@ Exception hierarchy The exception tree is defined in the `system `_ module: -.. include:: exception_hierarchy_fragment.txt +.. include:: ../exception_hierarchy_fragment.txt diff --git a/doc/manual/lexing.txt b/doc/manual/lexing.txt index 4187a60a44..4d03023c36 100644 --- a/doc/manual/lexing.txt +++ b/doc/manual/lexing.txt @@ -116,7 +116,7 @@ operator characters instead. The following keywords are reserved and cannot be used as identifiers: .. code-block:: nim - :file: keywords.txt + :file: ../keywords.txt Some keywords are unused; they are reserved for future developments of the language. diff --git a/doc/manual/syntax.txt b/doc/manual/syntax.txt index ca3b582ca4..4f7483be8d 100644 --- a/doc/manual/syntax.txt +++ b/doc/manual/syntax.txt @@ -119,6 +119,6 @@ Grammar The grammar's start symbol is ``module``. -.. include:: grammar.txt +.. include:: ../grammar.txt :literal: diff --git a/doc/manual/types.txt b/doc/manual/types.txt index a1596bceac..4c015ffb70 100644 --- a/doc/manual/types.txt +++ b/doc/manual/types.txt @@ -694,7 +694,7 @@ branch switch ``system.reset`` has to be used. Set type -------- -.. include:: sets_fragment.txt +.. include:: ../sets_fragment.txt Reference and pointer types --------------------------- diff --git a/doc/niminst.txt b/doc/niminst.txt index 7bd0f719e0..bf5cb0f50f 100644 --- a/doc/niminst.txt +++ b/doc/niminst.txt @@ -27,7 +27,7 @@ Configuration file niminst uses the Nim `parsecfg `_ module to parse the configuration file. Here's an example of how the syntax looks like: -.. include:: doc/mytest.cfg +.. include:: mytest.cfg :literal: The value of a key-value pair can reference user-defined variables via @@ -190,6 +190,6 @@ Real world example The installers for the Nim compiler itself are generated by niminst. Have a look at its configuration file: -.. include:: compiler/installer.ini +.. include:: ../compiler/installer.ini :literal: diff --git a/lib/core/macros.nim b/lib/core/macros.nim index bfda6b9389..16a954611a 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -12,7 +12,7 @@ include "system/inclrtl" ## This module contains the interface to the compiler's abstract syntax ## tree (`AST`:idx:). Macros operate on this tree. -## .. include:: ../doc/astspec.txt +## .. include:: ../../doc/astspec.txt type NimNodeKind* = enum diff --git a/lib/impure/re.nim b/lib/impure/re.nim index 60bb6c77f1..d49c6d1c16 100644 --- a/lib/impure/re.nim +++ b/lib/impure/re.nim @@ -22,7 +22,7 @@ ## though. ## PRCE's licence follows: ## -## .. include:: ../doc/regexprs.txt +## .. include:: ../../doc/regexprs.txt ## import diff --git a/lib/pure/net.nim b/lib/pure/net.nim index c734fe8937..cb8cea7206 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -606,28 +606,31 @@ proc setSockOpt*(socket: Socket, opt: SOBool, value: bool, level = SOL_SOCKET) { var valuei = cint(if value: 1 else: 0) setSockOptInt(socket.fd, cint(level), toCInt(opt), valuei) -when defined(posix) or defined(nimdoc): +when defined(posix) and not defined(nimdoc): proc makeUnixAddr(path: string): Sockaddr_un = result.sun_family = AF_UNIX.toInt if path.len >= Sockaddr_un_path_length: raise newException(ValueError, "socket path too long") copyMem(addr result.sun_path, path.cstring, path.len + 1) +when defined(posix): proc connectUnix*(socket: Socket, path: string) = ## Connects to Unix socket on `path`. ## This only works on Unix-style systems: Mac OS X, BSD and Linux - var socketAddr = makeUnixAddr(path) - if socket.fd.connect(cast[ptr SockAddr](addr socketAddr), - sizeof(socketAddr).Socklen) != 0'i32: - raiseOSError(osLastError()) + when not defined(nimdoc): + var socketAddr = makeUnixAddr(path) + if socket.fd.connect(cast[ptr SockAddr](addr socketAddr), + sizeof(socketAddr).Socklen) != 0'i32: + raiseOSError(osLastError()) proc bindUnix*(socket: Socket, path: string) = ## Binds Unix socket to `path`. ## This only works on Unix-style systems: Mac OS X, BSD and Linux - var socketAddr = makeUnixAddr(path) - if socket.fd.bindAddr(cast[ptr SockAddr](addr socketAddr), - sizeof(socketAddr).Socklen) != 0'i32: - raiseOSError(osLastError()) + when not defined(nimdoc): + var socketAddr = makeUnixAddr(path) + if socket.fd.bindAddr(cast[ptr SockAddr](addr socketAddr), + sizeof(socketAddr).Socklen) != 0'i32: + raiseOSError(osLastError()) when defined(ssl): proc handshake*(socket: Socket): bool @@ -1399,7 +1402,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), if selectWrite(s, timeout) != 1: raise newException(TimeoutError, "Call to 'connect' timed out.") else: - when defineSsl: + when defineSsl and not defined(nimdoc): if socket.isSSL: socket.fd.setBlocking(true) {.warning[Deprecated]: off.} diff --git a/lib/pure/parsecfg.nim b/lib/pure/parsecfg.nim index bf19d55408..25879d2b7c 100644 --- a/lib/pure/parsecfg.nim +++ b/lib/pure/parsecfg.nim @@ -15,21 +15,21 @@ ## This is an example of how a configuration file may look like: ## -## .. include:: doc/mytest.cfg +## .. include:: ../../doc/mytest.cfg ## :literal: ## The file ``examples/parsecfgex.nim`` demonstrates how to use the ## configuration file parser: ## ## .. code-block:: nim -## :file: examples/parsecfgex.nim -## +## :file: ../../examples/parsecfgex.nim +## ## Examples ## -------- ## ## This is an example of a configuration file. -## -## .. include:: config.ini -## +## +## :: +## ## charset = "utf-8" ## [Package] ## name = "hello" @@ -38,11 +38,11 @@ ## name = "lihf8515" ## qq = "10214028" ## email = "lihaifeng@wxm.com" -## +## ## Creating a configuration file. ## ============================== ## .. code-block:: nim -## +## ## import parsecfg ## var dict=newConfig() ## dict.setSectionKey("","charset","utf-8") @@ -52,7 +52,7 @@ ## dict.setSectionKey("Author","qq","10214028") ## dict.setSectionKey("Author","email","lihaifeng@wxm.com") ## dict.writeConfig("config.ini") -## +## ## Reading a configuration file. ## ============================= ## .. code-block:: nim @@ -66,11 +66,11 @@ ## var qq = dict.getSectionValue("Author","qq") ## var email = dict.getSectionValue("Author","email") ## echo pname & "\n" & name & "\n" & qq & "\n" & email -## +## ## Modifying a configuration file. ## =============================== ## .. code-block:: nim -## +## ## import parsecfg ## var dict = loadConfig("config.ini") ## dict.setSectionKey("Author","name","lhf") @@ -79,7 +79,7 @@ ## Deleting a section key in a configuration file. ## =============================================== ## .. code-block:: nim -## +## ## import parsecfg ## var dict = loadConfig("config.ini") ## dict.delSectionKey("Author","email") @@ -434,7 +434,7 @@ proc loadConfig*(filename: string): Config = ## Load the specified configuration file into a new Config instance. var dict = newOrderedTable[string, OrderedTableRef[string, string]]() var curSection = "" ## Current section, - ## the default value of the current section is "", + ## the default value of the current section is "", ## which means that the current section is a common var p: CfgParser var fileStream = newFileStream(filename, fmRead) diff --git a/lib/pure/parsexml.nim b/lib/pure/parsexml.nim index f8b2c3d8da..06daa37823 100644 --- a/lib/pure/parsexml.nim +++ b/lib/pure/parsexml.nim @@ -34,7 +34,7 @@ ## document. ## ## .. code-block:: nim -## :file: examples/htmltitle.nim +## :file: ../../examples/htmltitle.nim ## ## ## Example 2: Retrieve all HTML links @@ -45,7 +45,7 @@ ## an HTML document contains. ## ## .. code-block:: nim -## :file: examples/htmlrefs.nim +## :file: ../../examples/htmlrefs.nim ## import diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index eea20a62c5..7e1f50266d 100644 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -12,7 +12,7 @@ ## Matching performance is hopefully competitive with optimized regular ## expression engines. ## -## .. include:: ../doc/pegdocs.txt +## .. include:: ../../doc/pegdocs.txt ## include "system/inclrtl" diff --git a/lib/pure/random.nim b/lib/pure/random.nim index b5d046f948..c73f403eb7 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -7,9 +7,11 @@ # distribution, for details about the copyright. # -## | Nim's standard random number generator. Based on -## | http://xoroshiro.di.unimi.it/ -## | http://xoroshiro.di.unimi.it/xoroshiro128plus.c +##[Nim's standard random number generator. Based on + +| `http://xoroshiro.di.unimi.it/`_ +| `http://xoroshiro.di.unimi.it/xoroshiro128plus.c`_ +]## include "system/inclrtl" {.push debugger:off.} diff --git a/lib/pure/subexes.nim b/lib/pure/subexes.nim index 22f29b77cd..351b3c0867 100644 --- a/lib/pure/subexes.nim +++ b/lib/pure/subexes.nim @@ -9,7 +9,7 @@ ## Nim support for `substitution expressions`:idx: (`subex`:idx:). ## -## .. include:: ../doc/subexes.txt +## .. include:: ../../doc/subexes.txt ## {.push debugger:off .} # the user does not want to trace a part