Skip to content

Commit

Permalink
docs (Sphinx): added Bareos specific lexer for syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
joergsteffens committed Mar 15, 2019
1 parent ed3a293 commit 67cec37
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/manuals/en/new_main_reference/source/conf.py
Expand Up @@ -247,3 +247,14 @@
#scv_banner_main_ref = 'dev/pstorz/bareos-18.2/sphinx-versioning'

plantuml_output_format = 'svg_img'


#
# code-block highlighting
#
from sphinx.highlighting import lexers
from bareos_lexers import *
lexers['bareosconfig'] = BareosConfigLexer()
lexers['bconsole'] = BareosConsoleLexer()
lexers['bareoslog'] = BareosLogLexer()
lexers['bareosmessage'] = BareosMessageLexer()
@@ -0,0 +1,69 @@
from pygments.lexer import RegexLexer, inherit, bygroups
from pygments.lexers.shell import BashLexer
from pygments.token import *

#
# http://pygments.org/docs/lexerdevelopment/
# http://pygments.org/docs/tokens/
#

# Test:
# cat consolidate.cfg | pygmentize -l extensions/bareos_lexers.py:BareosConfigLexer -x
#

class BareosBaseLexer(BashLexer):
name = 'BareosBase'

tokens = {
'root': [
#(r'(<input>)(.*)(</input>)', bygroups(None, Generic.Emph, None)),
#(r'(<input>)(.*)(</input>)', bygroups(None, Generic.Strong, None)),
(r'(<input>)(.*)(</input>)', bygroups(None, Generic.Heading, None)),
(r'(<strong>)(.*)(</strong>)', bygroups(None, Generic.Strong, None)),
inherit,
],
}

class BareosConfigLexer(BareosBaseLexer):
name = 'BareosConfig'
aliases = ['bareosconfig', 'bconfig']
filenames = ['*.cfg']

tokens = {
'root': [
inherit,
],
}

class BareosConsoleLexer(BareosBaseLexer):
name = 'BareosConsole'
aliases = ['bareosconsole', 'bconsole']
#filenames = ['*.cfg']

tokens = {
'root': [
inherit,
],
}

class BareosLogLexer(BareosBaseLexer):
name = 'BareosLog'
aliases = ['bareoslog']
filenames = ['*.log']

tokens = {
'root': [
inherit,
],
}

class BareosMessageLexer(BareosBaseLexer):
name = 'BareosMessage'
aliases = ['bareosmessage', 'bmessage']
#filenames = ['*.log']

tokens = {
'root': [
inherit,
],
}

0 comments on commit 67cec37

Please sign in to comment.