def __init__(self, cfg): set_verbose_mode(cfg.verbose_mode) self.syntaxHighlighter = SqlHighlighter( highlight=cfg.syntaxHighlighting) self.dotEngine = Dot(cfg.output_dir) self.cfg = cfg self.html = HtmlWidgets(cfg.name, cfg.css, cfg.webEncoding, cfg.notNulls) self.index = {} # print html files debug_message('\nCreating HTML output') self._print_index_frames() self._print_list_pages() self._sanity_check() self._print_common_pages() debug_message('print tables') for table in cfg.schema.tables: self._print_table(table) debug_message('print views') for view in cfg.schema.views: self._print_view(view) debug_message('print materialized views') for mview in cfg.schema.mviews: self._print_mview(mview) debug_message('print functions') for function in cfg.schema.functions: self._print_function(function) debug_message('print procedures') for procedure in cfg.schema.procedures: self._print_procedure(procedure) debug_message('print packages') for package in cfg.schema.packages: self._print_package(package) debug_message('print java sources') for jsource in cfg.schema.java_sources: self._print_java_source(jsource) self._print_symbol_index_page()
def main(): """parse the command line args and run the formatting/writing of the documentation """ parser = argparse.ArgumentParser(description='Parse command line args.') # add all the possible arguments we expect to handle via the cli parser.add_argument('-u', dest='username', action='store', required=True, help='db schema') parser.add_argument('-p', dest='password', action='store', required=True, help='Password for the db schema') parser.add_argument('-t', dest='tsn', action='store', required=True, help='Network TSN alias') parser.add_argument('-o', dest='output_dir', action='store', required=True, help='Output directory for doc generation, for sphinx '\ 'documentation this is the same name as the schema '\ 'name so that links can be made between schemas.') parser.add_argument('-n', dest='name', action='store', required=False, default=False, help='DB Project name') parser.add_argument('-v', dest='verbose', action='store_true', default=False, help='Display verbose "build" text when running.') parser.add_argument('-s', dest='syntax_highlighting', action='store_true', default=False, help='When formatting as html, turn on syntax highlighting.') parser.add_argument('--css', dest='css', action='store', help='When formatting as html, path to custom css file') parser.add_argument('--noddl', dest='noddl', action='store_true', default=False, help='Diasble ddl generation') parser.add_argument('--dia', dest='dia', action='store_true', default=False, help='Enable dia uml output') parser.add_argument('--dia_conf_file', dest='dia_conf_file', action='store', help='Path to the dia conf table file. Only '\ 'create dia diagrams of tables in conf file') parser.add_argument('--desc', dest='description', action='store', help='Project description added to the documentation index') parser.add_argument('--dia-table-list', dest='dia-table-list', action='append', help='Filename for dia table lists') parser.add_argument('--not-nulls', dest='notnulls', action='store_true', default=False, help='Do not Write out the not null contraints') parser.add_argument('--pb', dest='pb', action='store_true', default=False, help='Do not write out the package bodies') group = parser.add_mutually_exclusive_group() group.add_argument('--html', dest='html', action='store_true', default=False, help='Format output as javadoc html files') group.add_argument('--rest', dest='rest', action='store_true', default=False, help='Format output as reST files') group.add_argument('--xml-file', dest='xml', action='store', help='Generate output into xml file') # create global config file - hanger passed around to various apps... # bleagh - but how it is in first fork.... cfg = OSDConfig() pargs = parser.parse_args() # username/schema username = pargs.username # do we want to generate ddl? cfg.allowDDL = not pargs.noddl # Just stick these as they are.... cfg.dia_conf_file = cfg.dia_conf_file name = pargs.name cfg.name = name and name or upper(username) cfg.notNulls = pargs.notnulls cfg.pb = pargs.pb cfg.xml_file = pargs.xml verbose = cfg.verbose = pargs.verbose set_verbose_mode(verbose) # make sure the dia conf file exists if set. if cfg.dia_conf_file: if not os.path.exists(cfg.cfg.dia_conf_file): cfg.dia_conf_file = None css = pargs.css if css: if not os.path.exists(os.path.join(cfg.csspath, css)): msg = '\nWARNING: %s doesn\'t exists. Using default instead.\n' % \ value debug_message(msg) else: cfg.css = css #if opt == '--schema': # cfg.useOwners = True # if len(value) > 0: # cfg.owners = value.split(',') # output dir is the dir the directory is created - based on:: # db.schema_name format - so /tmp/foo.username output_dir = os.path.join(os.path.abspath(pargs.output_dir), '%s.%s' % (pargs.tsn, username)) cfg.output_dir = output_dir # check if output_dir exsits, if not try to create one. if os.access(cfg.output_dir, os.F_OK) != 1: try: os.makedirs(cfg.output_dir) except os.error, e: print 'ERROR: Cannot create directory ', cfg.output_dir exit(2)
def __init__(self, cfg): self.cfg = cfg set_verbose_mode(cfg.verbose_mode)
def __init__(self, cfg): """! \param cfg a OSDConfig instance """ self.cfg = cfg set_verbose_mode(cfg.verbose_mode) debug_message('Oracle server %s (TNS: %s)' % \ (cfg.connection.version, cfg.connection.tnsentry)) # tables self.all_tables = self.__get_tables() self.all_table_names = self.all_tables.keys() self.all_table_names.sort() self.all_table_comments = self.__get_table_comments() self.all_tab_partitions = self.__get_tab_partitions() # columns self.all_columns = self.__get_columns() self.all_col_comments = self.__get_column_comments() # constraints self.all_constraints = self.__get_constraints() self.all_constraint_names = self.all_constraints.keys() self.all_constraint_names.sort() self.all_constraited_columns = self.__get_constraited_columns() # indexes self.all_indexes = self.__get_indexes() self.all_index_names = self.all_indexes.keys() self.all_index_names.sort() self.all_index_columns = self.__get_index_columns() self.all_index_expressions = self.__get_index_expressions() # views self.all_views = self.__get_views() self.all_view_names = self.all_views.keys() self.all_view_names.sort() self.all_updatable_columns = self.__get_updatable_columns() # materialized views (snapshots) self.all_mviews = self.__get_mviews() self.all_mview_names = self.all_mviews.keys() self.all_mview_names.sort() # table/view related mappings self.table_primary_key_map = {} self.table_unique_key_map = {} self.table_check_constraint_map = {} self.table_foreign_key_map = {} self.table_check_constraint_map = {} self.view_constraint_map = {} self.table_referenced_by = {} self.table_constraint_map= {} self.table_index_map = {} self.__set_table_maps() # triggers self.all_triggers = self.__get_triggers() self.all_trigger_names = self.all_triggers.keys() self.all_trigger_names.sort() self.all_trigger_columns = self.__get_trigger_columns() self.table_triggers = [] self.table_trigger_map = {} self.schema_triggers = [] self.__set_trigger_maps() # types self.types = self.__get_types() self.type_attributes = self.__get_type_attributes() self.type_methods = self.__get_type_methods() self.type_sources = {} self.type_body_sources = {} # pl/sql, java stuff self.all_functions = {} self.all_procedures = {} self.all_packages = {} self.all_package_bodies = {} self.all_java_sources = {} self.__set_user_sources() self.all_procedure_names = self.all_procedures.keys() self.all_procedure_names.sort() self.all_function_names = self.all_functions.keys() self.all_function_names.sort() self.all_package_names = self.all_packages.keys() self.all_package_names.sort() self.all_java_source_names = self.all_java_sources.keys() self.all_java_source_names.sort() # pl/sql arguments self.proc_arguments = {} self.func_return_arguments = {} self.package_arguments = {} self.package_return_values = {} self.__set_plsql_args() # sequences self.sequences = self.__get_sequences() self.sequence_names = self.sequences.keys() self.sequence_names.sort() # jobs self.jobs = self._getJobs() # dependencies # format { key : [ list of deps ] } self.dependencies = self.__getDependencies()