Documentation highlite (#11596)

* Add Documentation with examples for highlite

* Add Documentation with examples for highlite

(cherry picked from commit 206f2478b8)
This commit is contained in:
Juan Carlos
2019-06-26 05:28:11 -03:00
committed by narimiran
parent 48770b04bd
commit 50358e6d4a

View File

@@ -12,6 +12,33 @@
## The interface supports one language nested in another.
##
## **Note:** Import ``packages/docutils/highlite`` to use this module
##
## You can use this to build your own syntax highlighting, check this example:
##
## .. code::nim
## let code = """for x in $int.high: echo x.ord mod 2 == 0"""
## var toknizr: GeneralTokenizer
## initGeneralTokenizer(toknizr, code)
## while true:
## getNextToken(toknizr, langNim)
## case toknizr.kind
## of gtEof: break # End Of File (or string)
## of gtWhitespace:
## echo gtWhitespace # Maybe you want "visible" whitespaces?.
## echo substr(code, toknizr.start, toknizr.length + toknizr.start - 1)
## of gtOperator:
## echo gtOperator # Maybe you want Operators to use a specific color?.
## echo substr(code, toknizr.start, toknizr.length + toknizr.start - 1)
## # of gtSomeSymbol: syntaxHighlight("Comic Sans", "bold", "99px", "pink")
## else:
## echo toknizr.kind # All the kinds of tokens can be processed here.
## echo substr(code, toknizr.start, toknizr.length + toknizr.start - 1)
##
## The proc ``getSourceLanguage`` can get the language ``enum`` from a string:
##
## .. code::nim
## for l in ["C", "c++", "jAvA", "Nim", "c#"]: echo getSourceLanguage(l)
##
import
strutils