def run(argv): bauerGlobals = BauerGlobals() setupLogging(argv) generatorInfo = GeneratorInfo() argParser = BauerArgParser(bauerGlobals, generatorInfo) argParser.buildBauerArguments(argv) args = argParser.parse_args() if args == None: return if args.command == 'new': templateCreator = TemplateCreator() templateCreator.generate(args) return if args.command == 'doc': doccer = Documentation() doccer.run(args) return rootPath = os.path.abspath( os.path.join(os.path.realpath(__file__), "..", "..")) source_folder = os.getcwd() buildFolder = BuildFolder(bauerGlobals, generatorInfo, source_folder, args) commandProcessor = CommandProcessor(bauerGlobals, generatorInfo, args, rootPath, source_folder, buildFolder) commandProcessor.process()
class Client(TwistedClient): documentation = Documentation() THEMES = { # Matching theme names with Theme instances. TwistedClient.DEFAULTTHEME: documentation, 'documentation': documentation, 'doc': documentation, }
def parse(self, filename): tree = ElemTree.parse(filename) root = tree.getroot() resultlist = [] for classinfo in root.findall("classes"): result = Documentation() result.name = classinfo.attrib["name"] # Yes, the description is in an attrib called description in a node called description descriptionnode = classinfo.find("description") if descriptionnode is not None: result.description = descriptionnode.get("description") for propertyinfo in classinfo.findall("deviceProperties"): name = propertyinfo.attrib["name"] description = propertyinfo.attrib["description"] type = self.__get_type(propertyinfo) defaultnode = propertyinfo.find("DefaultPropValue") default = defaultnode.text if defaultnode is not None else "-" result.addproperty(name, description, type, default) for commandinfo in classinfo.findall("commands"): name = commandinfo.attrib["name"] description = commandinfo.attrib["description"] argin = commandinfo.find("argin") parameter_description = argin.get("description") parameter_type = self.__get_type(argin) argout = commandinfo.find("argout") result_description = argout.get("description") result_type = self.__get_type(argout) result.addcommand(name, description, parameter_type, parameter_description, result_type, result_description) for attributeinfo in classinfo.findall("attributes"): name = attributeinfo.get("name") description = attributeinfo.find("properties").get("description") type = self.__get_type(attributeinfo, "dataType") result.addattribute(name, description, type) resultlist.append(result) return resultlist
def run(argv): bauerGlobals = BauerGlobals() setupLogging(argv) generatorInfo = GeneratorInfo() argParser = BauerArgParser(bauerGlobals, generatorInfo) argParser.buildBauerArguments(argv) args = argParser.parse_args() if args == None: return if args.command == 'new': templateCreator = TemplateCreator() templateCreator.generate(args) return if args.command == 'doc': doccer = Documentation() doccer.run(args) return rootPath = os.path.abspath( os.path.join(os.path.realpath(__file__), "..", "..")) source_folder = os.getcwd() # Python will switch to the real path when the working dir has a symlink in it. # We'll update the current dir and the environment variable to reflect this. os.chdir(source_folder) os.environ["PWD"] = source_folder buildFolder = BuildFolder(bauerGlobals, generatorInfo, source_folder, args) commandProcessor = CommandProcessor(bauerGlobals, generatorInfo, args, rootPath, source_folder, buildFolder) commandProcessor.process()
def show(version, page=None): if not is_version(version): return redirect('/docs/' + DEFAULT_VERSION + '/' + version) if page is None: page = '' section_page = page if page else 'installation' content = Documentation.get(version, section_page) if content is None: abort(404) title = html.fromstring(content).xpath('//h1')[0].text section = '' if Documentation.section_exist(version, page): section += '/' + page elif page: return redirect('/docs' + version) canonical = '' if Documentation.section_exist(DEFAULT_VERSION, section_page): canonical = '/docs/' + DEFAULT_VERSION + '/' + section_page return render_template('docs.html', title=title, index=Documentation.get_index(version, page), content=content, current_version=version, versions=Documentation.get_doc_versions(), current_section=section, canonical=canonical)
def parse(self, device_url): device = DeviceProxy(device_url) result = Documentation() result.name = device.info().dev_class result.description = device.description() # FIXME: perhaps need to query the database about the propertiess propertyNames = device.get_property_list('*') for propertyName in propertyNames: result.addproperty(propertyName, 'TODO description', 'TODO type name', 'TODO default') attributeInfos = device.attribute_list_query() for attributeInfo in attributeInfos: result.addattribute(attributeInfo.name, attributeInfo.description, self.translate(attributeInfo.data_type, attributeInfo.data_format)) commandInfos = device.command_list_query() for commandInfo in commandInfos: result.addcommand( commandInfo.cmd_name, 'TODO command description', self.translate_command_argument(commandInfo.in_type), commandInfo.in_type_desc, self.translate_command_argument(commandInfo.out_type), commandInfo.out_type_desc) return [result]
def is_version(version): return version in Documentation.get_doc_versions()
from flask import Flask, render_template, redirect, abort from documentation import Documentation from lxml import html from werkzeug.contrib.cache import SimpleCache DEFAULT_VERSION = '0.12' app = Flask(__name__, static_url_path='') docs = Documentation(SimpleCache()) @app.route('/') def welcome(): return render_template('welcome.html', current_version=DEFAULT_VERSION) @app.route('/docs/') def show_root_page(): return redirect('/docs/' + DEFAULT_VERSION) @app.route('/docs/<version>/') @app.route('/docs/<version>/<page>') def show(version, page=None): if not is_version(version): return redirect('/docs/' + DEFAULT_VERSION + '/' + version, 301) if not page: page = ''
def __init__(self, soup): self._soup = soup self._documentation = Documentation()