Merge pull request #4157 from flaviut/update-nre-docs

Generate NRE docs for website
This commit is contained in:
Andreas Rumpf 2016-06-02 15:30:16 +02:00
commit 99be6dce81
4 changed files with 50 additions and 57 deletions

View file

@ -446,6 +446,10 @@ Regular expressions
This module contains procedures and operators for handling regular This module contains procedures and operators for handling regular
expressions. The current implementation uses PCRE. expressions. The current implementation uses PCRE.
* `nre <nre.html>`_
Another implementation of procedures for using regular expressions. Also uses
PCRE.
Database support Database support
---------------- ----------------

View file

@ -26,46 +26,35 @@ export options
## Licencing ## Licencing
## --------- ## ---------
## ##
## PCRE has some additional terms that you must comply with if you use this module.:: ## PCRE has `some additional terms`_ that you must agree to in order to use
## this module.
## ##
## > Copyright (c) 1997-2001 University of Cambridge ## .. _`some additional terms`: http://pcre.sourceforge.net/license.txt
## > ##
## > Permission is granted to anyone to use this software for any purpose on any ## Example
## > computer system, and to redistribute it freely, subject to the following ## -------
## > restrictions: ##
## > ## .. code-block:: nim
## > 1. This software is distributed in the hope that it will be useful, ##
## > but WITHOUT ANY WARRANTY; without even the implied warranty of ## import nre
## > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ##
## > ## let vowels = re"[aeoui]"
## > 2. The origin of this software must not be misrepresented, either by ##
## > explicit claim or by omission. In practice, this means that if you use ## for match in "moigagoo".findIter(vowels):
## > PCRE in software that you distribute to others, commercially or ## echo match.matchBounds
## > otherwise, you must put a sentence like this ## # (a: 1, b: 1)
## > ## # (a: 2, b: 2)
## > Regular expression support is provided by the PCRE library package, ## # (a: 4, b: 4)
## > which is open source software, written by Philip Hazel, and copyright ## # (a: 6, b: 6)
## > by the University of Cambridge, England. ## # (a: 7, b: 7)
## > ##
## > somewhere reasonably visible in your documentation and in any relevant ## import options # critical to use isSome() and get()
## > files or online help data or similar. A reference to the ftp site for ## let firstVowel = "foo".find(vowels)
## > the source, that is, to ## let hasVowel = firstVowel.isSome()
## > ## if hasVowel:
## > ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ ## let matchBounds = firstVowel.get().captureBounds[-1]
## > ## echo "first vowel @", matchBounds.get().a
## > should also be given in the documentation. However, this condition is not ## # first vowel @1
## > intended to apply to whole chains of software. If package A includes PCRE,
## > it must acknowledge it, but if package B is software that includes package
## > A, the condition is not imposed on package B (unless it uses PCRE
## > independently).
## >
## > 3. Altered versions must be plainly marked as such, and must not be
## > misrepresented as being the original software.
## >
## > 4. If PCRE is embedded in any software that is released under the GNU
## > General Purpose Licence (GPL), or Lesser General Purpose Licence (LGPL),
## > then the terms of that licence shall supersede any condition above with
## > which it is incompatible.
# Type definitions {{{ # Type definitions {{{
@ -127,11 +116,11 @@ type
## - ``(*NO_STUDY)`` - turn off studying; study is enabled by default ## - ``(*NO_STUDY)`` - turn off studying; study is enabled by default
## ##
## For more details on the leading option groups, see the `Option ## For more details on the leading option groups, see the `Option
## Setting <http://man7.org/linux/man-pages/man3/pcresyntax.3.html#OPTION_SETTING>`__ ## Setting <http://man7.org/linux/man-pages/man3/pcresyntax.3.html#OPTION_SETTING>`_
## and the `Newline ## and the `Newline
## Convention <http://man7.org/linux/man-pages/man3/pcresyntax.3.html#NEWLINE_CONVENTION>`__ ## Convention <http://man7.org/linux/man-pages/man3/pcresyntax.3.html#NEWLINE_CONVENTION>`_
## sections of the `PCRE syntax ## sections of the `PCRE syntax
## manual <http://man7.org/linux/man-pages/man3/pcresyntax.3.html>`__. ## manual <http://man7.org/linux/man-pages/man3/pcresyntax.3.html>`_.
pattern*: string ## not nil pattern*: string ## not nil
pcreObj: ptr pcre.Pcre ## not nil pcreObj: ptr pcre.Pcre ## not nil
pcreExtra: ptr pcre.ExtraData ## nil pcreExtra: ptr pcre.ExtraData ## nil
@ -495,17 +484,17 @@ proc matchImpl(str: string, pattern: Regex, start, endpos: int, flags: int): Opt
raise RegexInternalError(msg : "Unknown internal error: " & $execRet) raise RegexInternalError(msg : "Unknown internal error: " & $execRet)
proc match*(str: string, pattern: Regex, start = 0, endpos = int.high): Option[RegexMatch] = proc match*(str: string, pattern: Regex, start = 0, endpos = int.high): Option[RegexMatch] =
## Like ```find(...)`` <#proc-find>`__, but anchored to the start of the ## Like ```find(...)`` <#proc-find>`_, but anchored to the start of the
## string. This means that ``"foo".match(re"f") == true``, but ## string. This means that ``"foo".match(re"f") == true``, but
## ``"foo".match(re"o") == false``. ## ``"foo".match(re"o") == false``.
return str.matchImpl(pattern, start, endpos, pcre.ANCHORED) return str.matchImpl(pattern, start, endpos, pcre.ANCHORED)
iterator findIter*(str: string, pattern: Regex, start = 0, endpos = int.high): RegexMatch = iterator findIter*(str: string, pattern: Regex, start = 0, endpos = int.high): RegexMatch =
## Works the same as ```find(...)`` <#proc-find>`__, but finds every ## Works the same as ```find(...)`` <#proc-find>`_, but finds every
## non-overlapping match. ``"2222".find(re"22")`` is ``"22", "22"``, not ## non-overlapping match. ``"2222".find(re"22")`` is ``"22", "22"``, not
## ``"22", "22", "22"``. ## ``"22", "22", "22"``.
## ##
## Arguments are the same as ```find(...)`` <#proc-find>`__ ## Arguments are the same as ```find(...)`` <#proc-find>`_
## ##
## Variants: ## Variants:
## ##
@ -593,7 +582,7 @@ proc split*(str: string, pattern: Regex, maxSplit = -1, start = 0): seq[string]
## strings in the output seq. ## strings in the output seq.
## ``"1.2.3".split(re"\.", maxsplit = 2) == @["1", "2.3"]`` ## ``"1.2.3".split(re"\.", maxsplit = 2) == @["1", "2.3"]``
## ##
## ``start`` behaves the same as in ```find(...)`` <#proc-find>`__. ## ``start`` behaves the same as in ```find(...)`` <#proc-find>`_.
result = @[] result = @[]
var lastIdx = start var lastIdx = start
var splits = 0 var splits = 0

View file

@ -165,10 +165,10 @@ proc walkDirRecursively(s: var seq[string], root, ext: string) =
proc addFiles(s: var seq[string], dir, ext: string, patterns: seq[string]) = proc addFiles(s: var seq[string], dir, ext: string, patterns: seq[string]) =
for p in items(patterns): for p in items(patterns):
if existsFile(dir / addFileExt(p, ext)):
s.add(dir / addFileExt(p, ext))
if existsDir(dir / p): if existsDir(dir / p):
walkDirRecursively(s, dir / p, ext) walkDirRecursively(s, dir / p, ext)
else:
add(s, dir / addFileExt(p, ext))
proc parseIniFile(c: var TConfigData) = proc parseIniFile(c: var TConfigData) =
var var
@ -276,18 +276,18 @@ proc buildDoc(c: var TConfigData, destPath: string) =
commands = newSeq[string](len(c.doc) + len(c.srcdoc) + len(c.srcdoc2)) commands = newSeq[string](len(c.doc) + len(c.srcdoc) + len(c.srcdoc2))
i = 0 i = 0
for d in items(c.doc): for d in items(c.doc):
commands[i] = "nim rst2html $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" % commands[i] = "nim rst2html $# --docSeeSrcUrl:$#/$# -o:$# --index:on $#" %
[c.nimArgs, c.gitRepo, c.gitCommit, d.pathPart, [c.nimArgs, c.gitRepo, c.gitCommit,
destPath / changeFileExt(splitFile(d).name, "html"), d] destPath / changeFileExt(splitFile(d).name, "html"), d]
i.inc i.inc
for d in items(c.srcdoc): for d in items(c.srcdoc):
commands[i] = "nim doc $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" % commands[i] = "nim doc $# --docSeeSrcUrl:$#/$# -o:$# --index:on $#" %
[c.nimArgs, c.gitRepo, c.gitCommit, d.pathPart, [c.nimArgs, c.gitRepo, c.gitCommit,
destPath / changeFileExt(splitFile(d).name, "html"), d] destPath / changeFileExt(splitFile(d).name, "html"), d]
i.inc i.inc
for d in items(c.srcdoc2): for d in items(c.srcdoc2):
commands[i] = "nim doc2 $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" % commands[i] = "nim doc2 $# --docSeeSrcUrl:$#/$# -o:$# --index:on $#" %
[c.nimArgs, c.gitRepo, c.gitCommit, d.pathPart, [c.nimArgs, c.gitRepo, c.gitCommit,
destPath / changeFileExt(splitFile(d).name, "html"), d] destPath / changeFileExt(splitFile(d).name, "html"), d]
i.inc i.inc
@ -319,8 +319,8 @@ proc buildAddDoc(c: var TConfigData, destPath: string) =
# build additional documentation (without the index): # build additional documentation (without the index):
var commands = newSeq[string](c.webdoc.len) var commands = newSeq[string](c.webdoc.len)
for i, doc in pairs(c.webdoc): for i, doc in pairs(c.webdoc):
commands[i] = "nim doc2 $# --docSeeSrcUrl:$#/$#/$# -o:$# $#" % commands[i] = "nim doc2 $# --docSeeSrcUrl:$#/$# -o:$# $#" %
[c.nimArgs, c.gitRepo, c.gitCommit, doc.pathPart, [c.nimArgs, c.gitRepo, c.gitCommit,
destPath / changeFileExt(splitFile(doc).name, "html"), doc] destPath / changeFileExt(splitFile(doc).name, "html"), doc]
mexec(commands, c.numProcessors) mexec(commands, c.numProcessors)

View file

@ -35,7 +35,7 @@ doc: "nimfix.txt;nimsuggest.txt;nep1.txt;nims.txt"
pdf: "manual.txt;lib;tut1;tut2;nimc;niminst;gc" pdf: "manual.txt;lib;tut1;tut2;nimc;niminst;gc"
srcdoc2: "system.nim;system/nimscript;pure/ospaths" srcdoc2: "system.nim;system/nimscript;pure/ospaths"
srcdoc2: "core/macros;pure/marshal;core/typeinfo" srcdoc2: "core/macros;pure/marshal;core/typeinfo"
srcdoc2: "impure/re;pure/typetraits" srcdoc2: "impure/re;impure/nre;pure/typetraits"
srcdoc2: "pure/concurrency/threadpool.nim;pure/concurrency/cpuinfo.nim" srcdoc2: "pure/concurrency/threadpool.nim;pure/concurrency/cpuinfo.nim"
srcdoc: "system/threads.nim;system/channels.nim;js/dom" srcdoc: "system/threads.nim;system/channels.nim;js/dom"
srcdoc2: "pure/os;pure/strutils;pure/math;pure/matchers;pure/algorithm" srcdoc2: "pure/os;pure/strutils;pure/math;pure/matchers;pure/algorithm"