[doc] generate rc skeleton based on the order found in common/configopts
what is much better now already. Much better could be achived still once
This commit is contained in:
parent
0113e69463
commit
3f38529b0c
|
@ -4,41 +4,17 @@
|
||||||
# Copyright (C) 2008 Julien Danjou <julien@danjou.info>
|
# Copyright (C) 2008 Julien Danjou <julien@danjou.info>
|
||||||
# Copyright (C) 2008 Marco Candrian <mac@calmar.ws>
|
# Copyright (C) 2008 Marco Candrian <mac@calmar.ws>
|
||||||
#
|
#
|
||||||
# This indeed crappy. Any better version, even with awk, would be welcome.
|
# This is indeed crappy. Any better version, would be welcome.
|
||||||
|
|
||||||
|
|
||||||
print """Note: when there is no whitespace, quotes are optional.
|
|
||||||
|
|
||||||
<boolean> -> true or false
|
|
||||||
<color> -> Color in X format or hexadecimal (e.g. #aabbcc)
|
|
||||||
<float> -> Floating numbers (e.g 0.2)
|
|
||||||
<font> -> Pango font: [FAMILY-LIST] [STYLE-OPTIONS] [SIZE] (e.g Sans Italic 12)
|
|
||||||
<identifier> -> A name used to identify (e.g foobar)
|
|
||||||
<image> -> A path to an image (e.g. /home/user/image.jpg)
|
|
||||||
<integer> -> A signed integer
|
|
||||||
<key> -> A KeySym (e.g. F10) or a KeyCodea (e.g #120)
|
|
||||||
<mod> -> A key modifier list (e.g. Mod1)
|
|
||||||
<regex> -> Regular expression
|
|
||||||
<string> -> A string
|
|
||||||
<string-list> -> A string list (e.g. {a, b, c, ...})
|
|
||||||
<uicb-arg> -> Argument to an uicb function
|
|
||||||
<uicb-cmd> -> Uicb function, see UICB FUNCTIONS
|
|
||||||
<style section> -> A style section: {fg= bg= border= font= shadow= shadow_offset= }
|
|
||||||
<{.., ...}> -> List of available options
|
|
||||||
[MULTI] -> This item can be defined multiple times
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
indent = ""
|
sections = {} # [section_name] -> options infos (packed in option_doc's {})
|
||||||
section_desc = {} # [original_section_name] -> description
|
option_order = {} # [section_name] -> options in [] (ordered like found)
|
||||||
sections = {} # [original_section_name] -> items inside
|
section_desc = {} # [section_name] -> description of section itself
|
||||||
|
|
||||||
def sections_print(sec):
|
def sections_print(sec, indent):
|
||||||
global sections, section_desc, indent
|
global sections, section_desc, option_order
|
||||||
seclist = sections[sec].keys()
|
for opt in option_order[sec]:
|
||||||
seclist.sort()
|
|
||||||
for opt in seclist:
|
|
||||||
if sections[sec][opt][:9] == "<SECTION>":
|
if sections[sec][opt][:9] == "<SECTION>":
|
||||||
print indent + opt + section_desc[sections[sec][opt][9:]]
|
print indent + opt + section_desc[sections[sec][opt][9:]]
|
||||||
print indent + "{"
|
print indent + "{"
|
||||||
|
@ -46,7 +22,7 @@ def sections_print(sec):
|
||||||
if sections[sec][opt][9:] == "style_opts":
|
if sections[sec][opt][9:] == "style_opts":
|
||||||
print indent + "<style section>"
|
print indent + "<style section>"
|
||||||
else:
|
else:
|
||||||
sections_print(sections[sec][opt][9:])
|
sections_print(sections[sec][opt][9:], indent)
|
||||||
indent = indent[0:-4]
|
indent = indent[0:-4]
|
||||||
print indent + "}"
|
print indent + "}"
|
||||||
else:
|
else:
|
||||||
|
@ -84,36 +60,37 @@ def sections_print(sec):
|
||||||
print indent + opt + " = " + sections[sec][opt]
|
print indent + opt + " = " + sections[sec][opt]
|
||||||
|
|
||||||
def sections_get(file):
|
def sections_get(file):
|
||||||
global sections, section_desc
|
global sections, section_desc, option_order
|
||||||
section_doc = {} # holds all items from a section
|
option_doc = {} # holds all items from a section
|
||||||
section_begin = False
|
section_begin = False
|
||||||
for line in file.readlines():
|
for line in file.readlines():
|
||||||
if line.startswith("cfg_opt_t"):
|
if line.startswith("cfg_opt_t"):
|
||||||
section_name = (line.split(" ", 1)[1]).split("[]")[0]
|
section_name = (line.split(" ", 1)[1]).split("[]")[0]
|
||||||
section_begin = True
|
section_begin = True
|
||||||
|
option_order[section_name] = []
|
||||||
elif section_begin and line.startswith("};"):
|
elif section_begin and line.startswith("};"):
|
||||||
section_begin = False
|
section_begin = False
|
||||||
sections[section_name] = section_doc
|
sections[section_name] = option_doc
|
||||||
section_doc = {}
|
option_doc = {}
|
||||||
elif section_begin and line.startswith(" CFG_"):
|
elif section_begin and line.startswith(" CFG_"):
|
||||||
if line.startswith(" CFG_AWESOME_END"):
|
if line.startswith(" CFG_AWESOME_END"):
|
||||||
continue
|
continue
|
||||||
option_title = line.split("\"")[1].split("\"")[0]
|
option_title = line.split("\"")[1].split("\"")[0]
|
||||||
|
|
||||||
if line.startswith(" CFG_INT"):
|
if line.startswith(" CFG_INT"):
|
||||||
section_doc[option_title] = "<integer>"
|
option_doc[option_title] = "<integer>"
|
||||||
elif line.startswith(" CFG_BOOL"):
|
elif line.startswith(" CFG_BOOL"):
|
||||||
section_doc[option_title] = "<boolean>"
|
option_doc[option_title] = "<boolean>"
|
||||||
elif line.startswith(" CFG_FLOAT"):
|
elif line.startswith(" CFG_FLOAT"):
|
||||||
section_doc[option_title] = "<float>"
|
option_doc[option_title] = "<float>"
|
||||||
elif line.startswith(" CFG_ALIGNMENT"):
|
elif line.startswith(" CFG_ALIGNMENT"):
|
||||||
section_doc[option_title] = "<{left, center, right, flex, auto}>"
|
option_doc[option_title] = "<{left, center, right, flex, auto}>"
|
||||||
elif line.startswith(" CFG_POSITION"):
|
elif line.startswith(" CFG_POSITION"):
|
||||||
section_doc[option_title] = "<{top, bottom, left, right, auto, off}>"
|
option_doc[option_title] = "<{top, bottom, left, right, auto, off}>"
|
||||||
elif line.startswith(" CFG_STR_LIST"):
|
elif line.startswith(" CFG_STR_LIST"):
|
||||||
section_doc[option_title] = "<string-list>"
|
option_doc[option_title] = "<string-list>"
|
||||||
elif line.startswith(" CFG_STR"):
|
elif line.startswith(" CFG_STR"):
|
||||||
section_doc[option_title] = "<string>"
|
option_doc[option_title] = "<string>"
|
||||||
elif line.startswith(" CFG_SEC"):
|
elif line.startswith(" CFG_SEC"):
|
||||||
secname = (line.split(", ")[1]).split(",", 1)[0]
|
secname = (line.split(", ")[1]).split(",", 1)[0]
|
||||||
str = ""
|
str = ""
|
||||||
|
@ -124,12 +101,35 @@ def sections_get(file):
|
||||||
if line.find("CFGF_MULTI") != -1:
|
if line.find("CFGF_MULTI") != -1:
|
||||||
str += " [MULTI]"
|
str += " [MULTI]"
|
||||||
section_desc[secname] = str
|
section_desc[secname] = str
|
||||||
section_doc[option_title] = "<SECTION>" + secname
|
option_doc[option_title] = "<SECTION>" + secname
|
||||||
|
option_order[section_name].append(option_title)
|
||||||
|
|
||||||
lastline = line
|
lastline = line
|
||||||
|
|
||||||
|
def print_defines():
|
||||||
|
print """Note: when there is no whitespace, quotes are optional.
|
||||||
|
|
||||||
|
<boolean> -> true or false
|
||||||
|
<color> -> Color in X format or hexadecimal (e.g. #aabbcc)
|
||||||
|
<float> -> Floating numbers (e.g 0.2)
|
||||||
|
<font> -> Pango font: [FAMILY-LIST] [STYLE-OPTIONS] [SIZE] (e.g Sans Italic 12)
|
||||||
|
<identifier> -> A name used to identify (e.g foobar)
|
||||||
|
<image> -> A path to an image (e.g. /home/user/image.jpg)
|
||||||
|
<integer> -> A signed integer
|
||||||
|
<key> -> A KeySym (e.g. F10) or a KeyCodea (e.g #120)
|
||||||
|
<mod> -> A key modifier list (e.g. Mod1)
|
||||||
|
<regex> -> Regular expression
|
||||||
|
<string> -> A string
|
||||||
|
<string-list> -> A string list (e.g. {a, b, c, ...})
|
||||||
|
<uicb-arg> -> Argument to an uicb function
|
||||||
|
<uicb-cmd> -> Uicb function, see UICB FUNCTIONS
|
||||||
|
<style section> -> A style section: {fg= bg= border= font= shadow= shadow_offset= }
|
||||||
|
<{.., ...}> -> List of available options
|
||||||
|
[MULTI] -> This item can be defined multiple times
|
||||||
|
"""
|
||||||
sections_get(file(sys.argv[1]))
|
sections_get(file(sys.argv[1]))
|
||||||
|
|
||||||
sections_print("awesome_opts")
|
print_defines()
|
||||||
|
sections_print("awesome_opts", "")
|
||||||
|
|
||||||
# vim: filetype=python:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
# vim: filetype=python:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue