Fix header inconsistencies in documentation (#11071)
This commit is contained in:
parent
4f93669754
commit
3b4952da94
17 changed files with 95 additions and 98 deletions
|
|
@ -12,48 +12,46 @@
|
|||
## format, but much more powerful, as it is not a line based parser. String
|
||||
## literals, raw string literals and triple quoted string literals are supported
|
||||
## as in the Nim programming language.
|
||||
|
||||
## This is an example of how a configuration file may look like:
|
||||
##
|
||||
## Example of how a configuration file may look like:
|
||||
##
|
||||
## .. include:: ../../doc/mytest.cfg
|
||||
## :literal:
|
||||
##
|
||||
|
||||
##[ Here is an example of how to use the configuration file parser:
|
||||
|
||||
.. code-block:: nim
|
||||
|
||||
import
|
||||
os, parsecfg, strutils, streams
|
||||
|
||||
var f = newFileStream(paramStr(1), fmRead)
|
||||
if f != nil:
|
||||
var p: CfgParser
|
||||
open(p, f, paramStr(1))
|
||||
while true:
|
||||
var e = next(p)
|
||||
case e.kind
|
||||
of cfgEof: break
|
||||
of cfgSectionStart: ## a ``[section]`` has been parsed
|
||||
echo("new section: " & e.section)
|
||||
of cfgKeyValuePair:
|
||||
echo("key-value-pair: " & e.key & ": " & e.value)
|
||||
of cfgOption:
|
||||
echo("command: " & e.key & ": " & e.value)
|
||||
of cfgError:
|
||||
echo(e.msg)
|
||||
close(p)
|
||||
else:
|
||||
echo("cannot open: " & paramStr(1))
|
||||
|
||||
]##
|
||||
|
||||
## Here is an example of how to use the configuration file parser:
|
||||
##
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## import os, parsecfg, strutils, streams
|
||||
##
|
||||
## var f = newFileStream(paramStr(1), fmRead)
|
||||
## if f != nil:
|
||||
## var p: CfgParser
|
||||
## open(p, f, paramStr(1))
|
||||
## while true:
|
||||
## var e = next(p)
|
||||
## case e.kind
|
||||
## of cfgEof: break
|
||||
## of cfgSectionStart: ## a ``[section]`` has been parsed
|
||||
## echo("new section: " & e.section)
|
||||
## of cfgKeyValuePair:
|
||||
## echo("key-value-pair: " & e.key & ": " & e.value)
|
||||
## of cfgOption:
|
||||
## echo("command: " & e.key & ": " & e.value)
|
||||
## of cfgError:
|
||||
## echo(e.msg)
|
||||
## close(p)
|
||||
## else:
|
||||
## echo("cannot open: " & paramStr(1))
|
||||
##
|
||||
##
|
||||
## Examples
|
||||
## --------
|
||||
## ========
|
||||
##
|
||||
## This is an example of a configuration file.
|
||||
## Configuration file example
|
||||
## --------------------------
|
||||
##
|
||||
## ::
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## charset = "utf-8"
|
||||
## [Package]
|
||||
|
|
@ -64,8 +62,8 @@
|
|||
## qq = "10214028"
|
||||
## email = "lihaifeng@wxm.com"
|
||||
##
|
||||
## Creating a configuration file.
|
||||
## ==============================
|
||||
## Creating a configuration file
|
||||
## -----------------------------
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## import parsecfg
|
||||
|
|
@ -78,8 +76,8 @@
|
|||
## dict.setSectionKey("Author","email","lihaifeng@wxm.com")
|
||||
## dict.writeConfig("config.ini")
|
||||
##
|
||||
## Reading a configuration file.
|
||||
## =============================
|
||||
## Reading a configuration file
|
||||
## ----------------------------
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## import parsecfg
|
||||
|
|
@ -92,8 +90,8 @@
|
|||
## var email = dict.getSectionValue("Author","email")
|
||||
## echo pname & "\n" & name & "\n" & qq & "\n" & email
|
||||
##
|
||||
## Modifying a configuration file.
|
||||
## ===============================
|
||||
## Modifying a configuration file
|
||||
## ------------------------------
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## import parsecfg
|
||||
|
|
@ -101,8 +99,8 @@
|
|||
## dict.setSectionKey("Author","name","lhf")
|
||||
## dict.writeConfig("config.ini")
|
||||
##
|
||||
## Deleting a section key in a configuration file.
|
||||
## ===============================================
|
||||
## Deleting a section key in a configuration file
|
||||
## ----------------------------------------------
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## import parsecfg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue