2008-04-08 03:56:03 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# extractuicbdoc.py - extract uicb documentation from awesome source code
|
2008-04-08 08:28:37 +02:00
|
|
|
# Copyright (C) 2008 Julien Danjou <julien@danjou.info>
|
2008-04-08 03:56:03 +02:00
|
|
|
# Copyright (C) 2008 Marco Candrian <mac@calmar.ws>
|
|
|
|
#
|
2008-04-09 03:03:53 +02:00
|
|
|
# This is indeed crappy. Any better version, would be welcome.
|
2008-04-08 03:56:03 +02:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2008-04-09 03:03:53 +02:00
|
|
|
sections = {} # [section_name] -> options infos (packed in option_doc's {})
|
|
|
|
option_order = {} # [section_name] -> options in [] (ordered like found)
|
|
|
|
section_desc = {} # [section_name] -> description of section itself
|
2008-04-08 03:56:03 +02:00
|
|
|
|
2008-04-09 03:03:53 +02:00
|
|
|
def sections_print(sec, indent):
|
|
|
|
global sections, section_desc, option_order
|
|
|
|
for opt in option_order[sec]:
|
2008-04-08 03:56:03 +02:00
|
|
|
if sections[sec][opt][:9] == "<SECTION>":
|
|
|
|
print indent + opt + section_desc[sections[sec][opt][9:]]
|
|
|
|
print indent + "{"
|
|
|
|
indent += " "
|
|
|
|
if sections[sec][opt][9:] == "style_opts":
|
|
|
|
print indent + "<style section>"
|
|
|
|
else:
|
2008-04-09 03:03:53 +02:00
|
|
|
sections_print(sections[sec][opt][9:], indent)
|
2008-04-08 03:56:03 +02:00
|
|
|
indent = indent[0:-4]
|
|
|
|
print indent + "}"
|
|
|
|
else:
|
|
|
|
if opt in ["fg", "bg", "fg_center", "fg_end", "fg_off", "bordercolor",
|
|
|
|
"tab_border","normal_fg","normal_bg","normal_border","focus_fg",
|
|
|
|
"focus_bg","focus_border","urgent_fg","urgent_bg"]:
|
|
|
|
print indent + opt + " = <color>"
|
|
|
|
elif opt in ["font"]:
|
|
|
|
print indent + opt + " = <font>"
|
|
|
|
elif opt in ["image"]:
|
|
|
|
print indent + opt + " = <image>"
|
|
|
|
elif opt in ["name", "xproperty_value", "tags"]:
|
|
|
|
print indent + opt + " = <regex>"
|
|
|
|
elif opt in ["key"]:
|
|
|
|
print indent + opt + " = <key>"
|
|
|
|
elif opt in ["keylist"]:
|
|
|
|
print indent + opt + " = <key, ...>"
|
|
|
|
elif opt in ["modkey"]:
|
|
|
|
print indent + opt + " = <mod>"
|
2008-04-09 02:21:54 +02:00
|
|
|
elif opt in ["align"]:
|
|
|
|
print indent + opt + " = <{auto, left, right}>"
|
|
|
|
elif opt in ["text_align"]:
|
|
|
|
print indent + opt + " = <{left, center, right}>"
|
2008-04-14 03:10:30 +02:00
|
|
|
elif opt in ["grow"]:
|
|
|
|
print indent + opt + " = <{left, right}>"
|
2008-04-08 03:56:03 +02:00
|
|
|
elif opt in ["arg"]:
|
|
|
|
print indent + opt + " = <uicb-arg>"
|
|
|
|
elif opt in ["command"]:
|
|
|
|
print indent + opt + " = <uicb-cmd>"
|
|
|
|
elif opt in ["float", "master"]:
|
|
|
|
print indent + opt + " = <{auto,true,false}>"
|
|
|
|
elif opt in ["show"]:
|
|
|
|
print indent + opt + " = <{all,tags,focus}>"
|
|
|
|
elif opt in ["floating_placement"]:
|
|
|
|
print indent + opt + " = <{smart,under_mouse}>"
|
|
|
|
else:
|
|
|
|
print indent + opt + " = " + sections[sec][opt]
|
|
|
|
|
|
|
|
def sections_get(file):
|
2008-04-09 03:03:53 +02:00
|
|
|
global sections, section_desc, option_order
|
|
|
|
option_doc = {} # holds all items from a section
|
2008-04-08 03:56:03 +02:00
|
|
|
section_begin = False
|
|
|
|
for line in file.readlines():
|
|
|
|
if line.startswith("cfg_opt_t"):
|
|
|
|
section_name = (line.split(" ", 1)[1]).split("[]")[0]
|
|
|
|
section_begin = True
|
2008-04-09 03:03:53 +02:00
|
|
|
option_order[section_name] = []
|
2008-04-08 03:56:03 +02:00
|
|
|
elif section_begin and line.startswith("};"):
|
|
|
|
section_begin = False
|
2008-04-09 03:03:53 +02:00
|
|
|
sections[section_name] = option_doc
|
|
|
|
option_doc = {}
|
2008-04-08 03:56:03 +02:00
|
|
|
elif section_begin and line.startswith(" CFG_"):
|
|
|
|
if line.startswith(" CFG_AWESOME_END"):
|
|
|
|
continue
|
|
|
|
option_title = line.split("\"")[1].split("\"")[0]
|
|
|
|
|
|
|
|
if line.startswith(" CFG_INT"):
|
2008-04-09 03:03:53 +02:00
|
|
|
option_doc[option_title] = "<integer>"
|
2008-04-08 03:56:03 +02:00
|
|
|
elif line.startswith(" CFG_BOOL"):
|
2008-04-09 03:03:53 +02:00
|
|
|
option_doc[option_title] = "<boolean>"
|
2008-04-08 03:56:03 +02:00
|
|
|
elif line.startswith(" CFG_FLOAT"):
|
2008-04-09 03:03:53 +02:00
|
|
|
option_doc[option_title] = "<float>"
|
2008-04-08 03:56:03 +02:00
|
|
|
elif line.startswith(" CFG_ALIGNMENT"):
|
2008-04-09 03:03:53 +02:00
|
|
|
option_doc[option_title] = "<{left, center, right, flex, auto}>"
|
2008-04-08 03:56:03 +02:00
|
|
|
elif line.startswith(" CFG_POSITION"):
|
2008-04-09 03:03:53 +02:00
|
|
|
option_doc[option_title] = "<{top, bottom, left, right, auto, off}>"
|
2008-04-08 03:56:03 +02:00
|
|
|
elif line.startswith(" CFG_STR_LIST"):
|
2008-04-09 03:03:53 +02:00
|
|
|
option_doc[option_title] = "<string-list>"
|
2008-04-08 03:56:03 +02:00
|
|
|
elif line.startswith(" CFG_STR"):
|
2008-04-09 03:03:53 +02:00
|
|
|
option_doc[option_title] = "<string>"
|
2008-04-08 03:56:03 +02:00
|
|
|
elif line.startswith(" CFG_SEC"):
|
|
|
|
secname = (line.split(", ")[1]).split(",", 1)[0]
|
|
|
|
str = ""
|
|
|
|
if line.find("CFGF_NO_TITLE_DUPES") != -1:
|
|
|
|
str += " <identifier>"
|
|
|
|
elif line.find("CFGF_TITLE") != -1:
|
|
|
|
str += " <title>"
|
|
|
|
if line.find("CFGF_MULTI") != -1:
|
|
|
|
str += " [MULTI]"
|
|
|
|
section_desc[secname] = str
|
2008-04-09 03:03:53 +02:00
|
|
|
option_doc[option_title] = "<SECTION>" + secname
|
|
|
|
option_order[section_name].append(option_title)
|
2008-04-08 03:56:03 +02:00
|
|
|
|
|
|
|
lastline = line
|
|
|
|
|
2008-04-09 03:03:53 +02:00
|
|
|
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
|
|
|
|
"""
|
2008-04-08 03:56:03 +02:00
|
|
|
sections_get(file(sys.argv[1]))
|
|
|
|
|
2008-04-09 03:03:53 +02:00
|
|
|
print_defines()
|
|
|
|
sections_print("awesome_opts", "")
|
2008-04-08 03:56:03 +02:00
|
|
|
|
|
|
|
# vim: filetype=python:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|