[pygccxml-commit] SF.net SVN: pygccxml:[1658] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-02-04 16:32:10
|
Revision: 1658 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1658&view=rev Author: roman_yakovenko Date: 2009-02-04 16:32:04 +0000 (Wed, 04 Feb 2009) Log Message: ----------- sphinx Modified Paths: -------------- pydsc_dev/pydsc.py pydsc_dev/unittests/tester.py pydsc_dev/unittests/to_be_tested.py pygccxml_dev/pygccxml/__init__.py pygccxml_dev/pygccxml/declarations/algorithm.py pygccxml_dev/pygccxml/declarations/class_declaration.py pygccxml_dev/pygccxml/declarations/enumeration.py pygccxml_dev/pygccxml/declarations/matcher.py pygccxml_dev/pygccxml/declarations/matchers.py pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py pygccxml_dev/pygccxml/declarations/namespace.py pygccxml_dev/pygccxml/declarations/scopedef.py pygccxml_dev/pygccxml/declarations/templates.py pygccxml_dev/pygccxml/utils/__init__.py pygccxml_dev/unittests/autoconfig.py Modified: pydsc_dev/pydsc.py =================================================================== --- pydsc_dev/pydsc.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pydsc_dev/pydsc.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -22,8 +22,8 @@ __license__ = 'Boost Software License <http://boost.org/more/license_info.html>' #license import os +import re import sys -import pdb import pprint import inspect import __builtin__ @@ -33,59 +33,38 @@ """return os.path.normcase( os.path.normpath( some_path ) )""" return os.path.normcase( os.path.normpath( some_path ) ) -class filter_by_path_t: +def contains_parent_dir( path, dirs ): """ - Utility class, should not be used directly. - """ + returns true if one of the directories is root directory for the `path`, false otherwise - class FILTER_TYPE: - """ - defines few filter constants + :param path: path to be checked + :type path: str - - *INCLUDE* - - *EXCLUDE* - """ - INCLUDE = 'include' - EXCLUDE = 'exclude' + :param dirs: list of directories and\\or files + :type dirs: [ str ] - def __init__( self, what, ftype ): - """ - :parameters: - - `what` - could be file or directory name, or list of them - - `ftype` - one of the :const:`FILTER_TYPE` constants - """ - self.what = what - if None is self.what: - self.what = [] - elif isinstance( self.what, str ): - self.what = [self.what] - self.what = map( normalize_path, self.what ) - self.ftype = ftype + :rtype: bool + """ + #precondition: dirs and fpath should be normalize_path'ed before calling this function + return bool( filter( lambda dir: path.startswith( dir ), dirs ) ) - @staticmethod - def contains_parent_dir( path, dirs ): - """ - returns true if one of the directories is root directory for the `path`, false otherwise +def is_identifier( word ): + """ + returns `True` is the word represents an identifier, constructed from two or more words, `False` otherwise. - :param path: path - :type path: str + This function is used to filter out some errors, reported by spell checker. + """ + if not word: + return False + if '_' in word: + return True + rest_of_word = word[1:] + for ch in rest_of_word: + if ch == ch.upper(): + return True + return False - :param dirs: list of directories and\\or files - :type dirs: [ str ] - :rtype: bool - """ - #precondition: dirs and fpath should be normalize_path'ed before calling this function - return bool( filter( lambda dir: path.startswith( dir ), dirs ) ) - - def check( self, source_file ): - """returns True if source_file should be checked, False otherwise""" - source_file = normalize_path( source_file ) - if source_file in self.what or self.contains_parent_dir( source_file, self.what ): - return self.ftype == self.FILTER_TYPE.INCLUDE - else: - return self.ftype == self.FILTER_TYPE.EXCLUDE - class checker_t( object ): """ Applies spell check process on every imported module. @@ -98,8 +77,8 @@ def __init__( self , speller , writer=None - , filter=None - , ignore_identifiers=True ): + , ignore_identifiers=True + , text_preprocessor=None ): """ initialization method @@ -113,9 +92,6 @@ :param writer: reference to instance of class that has write method. By default sys.stdout will be used. - :param filter: list of files or directories - :type filter: [ str ] - :param filter_type: provides interpretation for content of filter parameter :type filter_type: L{FILTER_TYPE} @@ -124,6 +100,9 @@ usually introduce spell error. If ignore_identifiers set to True, those names will be ignored. :type ignore_identifiers: bool + + :param text_preprocessor: a callable, which takes a text before it is passed to + the spell checker. The result will be passed to the spell checker. """ object.__init__( self ) self.__checked = set() @@ -135,13 +114,24 @@ self.writer = writer if self.writer is None: self.writer = sys.stdout - self.filter = filter + self.__include_paths = set() self.ignored_words = set() + self.add_include_paths( '.') self.ignore_identifiers = ignore_identifiers + self.text_preprocessor = text_preprocessor + if not self.text_preprocessor: + self.text_preprocessor = lambda t: t + def add_include_paths( self, path ): + np = lambda p: normalize_path( os.path.abspath( p ) ) + if isinstance( path, str ): + self.__include_paths.add( np( path ) ) + else: + for pi in path: + self.__include_paths.add( np( pi ) ) + def should_be_checked( self, obj, module=None ): """returns True, if obj should be checked, False otherwise""" - if id(obj) in self.__checked: return False if inspect.isbuiltin( obj ): @@ -149,16 +139,11 @@ if inspect.ismodule( obj ): if obj.__name__ in self.__already_imported: return False #do not check already imported modules - if self.filter: - try: - source_file = self.getsourcefile(obj) - if source_file is None: - source_file = inspect.getfile( obj ) - return self.filter.check( source_file ) - except TypeError: - return False #built in module + source_file = self.getsourcefile(obj) + if source_file: + return contains_parent_dir( source_file, self.__include_paths ) else: - return True + return False obj_module = inspect.getmodule( obj ) if not obj_module is module: return False @@ -182,20 +167,43 @@ @staticmethod def getsourcefile( obj ): try: - return inspect.getsourcefile( obj ) + fpath = inspect.getsourcefile( obj ) + if fpath is None: + fpath = inspect.getfile( obj ) + if fpath: + fpath = os.path.abspath( fpath ) + fpath = normalize_path( fpath ) + return fpath except TypeError: pass - def __check_text_impl( self, obj, text, text_type ): + def __get_local_ignored_words( self, obj ): + names = set() + if inspect.ismethod( obj ) or inspect.isfunction( obj ): + args_desc = inspect.getargspec( obj ) + names.update( args_desc[0] ) + if args_desc[1]: + names.add( args_desc[1] ) + if args_desc[2]: + names.add( args_desc[2] ) + return names + + def __check_text_impl( self, obj, text_, text_type ): + text = self.text_preprocessor( text_ ) if not text: return if self.ignore_identifiers and hasattr( obj, '__name__' ) and obj.__name__: self.ignored_words.add( obj.__name__ ) + + local_ignored_words = self.__get_local_ignored_words( obj ) + errors = {} self.speller.set_text( text ) for error in self.speller: - if error.word in self.ignored_words: + if error.word in self.ignored_words or error.word in local_ignored_words: continue + if is_identifier( error.word ): + continue if not errors.has_key( error.word ): errors[ error.word ] = [] errors[ error.word ] = self.speller.suggest() @@ -204,8 +212,7 @@ write = self.writer.write if self.getsourcefile( inspect.getmodule( obj ) ): write( ' error details: %s' % os.linesep ) - write( ' file : %s%s' % ( self.getsourcefile( inspect.getmodule( obj ) ), os.linesep ) ) - write( ' line : %d%s' % ( inspect.getsourcelines( obj )[1], os.linesep ) ) + write( ' location : %s:%d%s' % ( self.getsourcefile( inspect.getmodule( obj ) ), 1 + inspect.getsourcelines( obj )[1], os.linesep ) ) write( ' text type : %s%s' % ( text_type, os.linesep ) ) else: write( ' error details: %s' % os.linesep ) @@ -213,6 +220,9 @@ for word, suggestions in errors.items(): write( ' misspelled word: %s%s' % ( word, os.linesep ) ) write( ' suggestions : %s%s' % ( `suggestions`, os.linesep ) ) + clean = lambda t: t.replace( '\n', ' ' ).replace( '\r', '' ) + write( ' source file text: %s\n' % clean( text_ ) ) + write( ' checked text : %s\n' % clean( text ) ) def __check_text( self, obj): self.__check_text_impl( obj, inspect.getdoc( obj ), 'documentation string' ) @@ -237,27 +247,20 @@ doc_checker = None if 'PYDSC' in os.environ: if not 'sphinx' in os.environ['PYDSC']: - doc_checker = checker_t( checker.SpellChecker( "en_US" ) ) + doc_checker = checker_t( checker.SpellChecker( "en_US" )) #, filters=[checker.EmailFilter,checker.URLFilter] ) ) else: - doc_checker = checker_t( checker.SpellChecker( "en_US" ) ) + doc_checker = checker_t( checker.SpellChecker( "en_US" ))#, filters=[checker.EmailFilter,checker.URLFilter, checker.WikiWordFilter] ) ) -def exclude( what ): - """ - excludes all modules, from the check process, that are lying in *what* directory(ies) - *what* - a path or list of paths, could be or contain file and/or directory names +def include_paths( what ): """ - doc_checker.filter = filter_by_path_t( what, filter_by_path_t.FILTER_TYPE.EXCLUDE ) - -def include( what ): - """ includes all modules, to the check process, that are lying in *what* directory(ies) *what* - a path or list of paths, could be or contain file and/or directory names """ - doc_checker.filter = filter_by_path_t( what, filter_by_path_t.FILTER_TYPE.INCLUDE ) + doc_checker.add_include_paths( what ) -def ignore( what, case_sensitive=False ): +def ignore_words( what, case_sensitive=False ): """ adds *what*, word or list of words, to the ignore list. @@ -270,6 +273,42 @@ else: for word in what: if case_sensitive: - word = what.lower() + word = word.lower() doc_checker.ignored_words.add( word ) +def ignore_dictionary( path, case_sensitive=False ): + """ + adds all words from file to the "ignore" list + + The file should contain one word per line + + :param path: path to dictionary file + :type path: str + """ + for w in file( path, 'r' ).readlines(): + w = w.strip() + if case_sensitive: + w = w.lower() + if w: + doc_checker.ignored_words.add( w ) + +def set_text_preprocessor( preprocessor ): + doc_checker.text_preprocessor = preprocessor + +__ref_def = re.compile( r':[_a-zA-Z]+(\s+[_a-zA-Z]+)?:' ) +__ref_no_title = re.compile( r'`(\:\:)?[_a-zA-Z]+[_a-zA-Z0-9\.\:]*`' ) +__ref_with_title = re.compile( r'`(?P<text>.+)?\s(\<.*\>)`' ) + +def sphinx_preprocessor( text ): + def replace( m ): + if 'text' in m.groupdict(): + return ' ' * ( m.start( 'text' ) - m.start() ) + m.group( 'text' ) + ' ' * ( m.end() - m.end( 'text' ) ) + else: + return ' ' * ( m.end() - m.start() ) + if not text: + return text + result = text + result = __ref_no_title.sub( replace, result ) + result = __ref_def.sub( replace, result ) + result = __ref_with_title.sub( replace, result ) + return result Modified: pydsc_dev/unittests/tester.py =================================================================== --- pydsc_dev/unittests/tester.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pydsc_dev/unittests/tester.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -9,8 +9,7 @@ import pydsc -pydsc.exclude( os.path.abspath( os.path.join( os.curdir, 'do_not_check' ) ) ) -pydsc.ignore( 'abracadabra' ) +pydsc.ignore_words( 'abracadabra' ) import to_be_tested import do_not_check Modified: pydsc_dev/unittests/to_be_tested.py =================================================================== --- pydsc_dev/unittests/to_be_tested.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pydsc_dev/unittests/to_be_tested.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -11,6 +11,9 @@ code_creator_t is the base class for all code creators. This class defines interface that every code creator should implement. Also it provides few convinience functions. + + + qeqerqwerqwerqwer """ PYPLUSPLUS_NS_NAME = 'pyplusplus' __INDENTATION = ' ' Modified: pygccxml_dev/pygccxml/__init__.py =================================================================== --- pygccxml_dev/pygccxml/__init__.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/__init__.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -12,19 +12,16 @@ XML file. This XML file is then read by pygccxml and the contents are made available as appropriate Python objects. -To parse a set of C/C++ header files you use the -L{parse()<parser.parse>} function in the L{parser} sub package which -returns a tree that contains all declarations found in the header -files. The root of the tree represents the main namespace C{::} and -the children nodes represent the namespace contents such as other -namespaces, classes, functions, etc. Each node in the tree is an -object of a type derived from the -L{declaration_t<declarations.declaration_t>} base class. An inner -node is always either a namespace (L{namespace_t<declarations.namespace_t>}) -or a class (L{class_t<declarations.class_t>}) which are both derived -from L{scopedef_t<declarations.scopedef_t>}. Everything else (free functions, -member functions, enumerations, variables, etc.) is always a leaf. -You will find all those declaration classes in the L{declarations} +To parse a set of C/C++ header files you use the :func:`parse <parser.parse>` +function in the :mod:parser sub package which returns a tree that contains all +declarations found in the header files. The root of the tree represents the main +namespace `::` and the children nodes represent the namespace contents such as other +namespaces, classes, functions, etc. Each node in the tree is an object of a type +derived from the :class:`declaration_t` class. An inner node is always either a +namespace :class:`declarations.namespace_t` or a class :class:`declarations.class_t`, +which are both derived from :class:`declarations.scopedef_t` class. Everything +else (free functions, member functions, enumerations, variables, etc.) is always +a leaf. You will find all those declaration classes in the :mod:declarations sub-package. """ Modified: pygccxml_dev/pygccxml/declarations/algorithm.py =================================================================== --- pygccxml_dev/pygccxml/declarations/algorithm.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/algorithm.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -15,7 +15,7 @@ :type decl: :class:`declaration_t` :rtype: [names], where first item contains top parent name and last item - contains decl name + contains the `decl` name """ if not decl: return [] @@ -45,7 +45,7 @@ :type decl: :class:`declaration_t` :rtype: [names], where first item contains top parent name and last item - contains decl name + contains the `decl` name """ #TODO: #If parent declaration cache already has declaration_path, reuse it for @@ -98,8 +98,8 @@ def full_name( decl, with_defaults=True ): """ returns declaration full qualified name - - If `decl` belongs to anonymious namespace or class, the function will return C++ illegal qualified name. + + If `decl` belongs to anonymous namespace or class, the function will return C++ illegal qualified name. :param decl: :class:`declaration_t` :type decl: :class:`declaration_t` :rtype: full name of declarations. Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/class_declaration.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -501,7 +501,7 @@ return get_partial_name( self.name ) def find_noncopyable_vars( self ): - """returns list of all noncopyable variables""" + """returns list of all `noncopyable` variables""" import type_traits as tt#prevent cyclic dependencies logger = utils.loggers.cxx_parser mvars = self.vars( lambda v: not v.type_qualifiers.has_static, recursive=False, allow_empty=True ) Modified: pygccxml_dev/pygccxml/declarations/enumeration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/enumeration.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/enumeration.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -4,7 +4,7 @@ # http://www.boost.org/LICENSE_1_0.txt) """ -defines class, that describes C++ enum +defines class, that describes C++ `enum` """ import copy @@ -14,15 +14,15 @@ class enumeration_t( declaration.declaration_t ): """ - describes C++ enum + describes C++ `enum` """ def __init__( self, name='', values=None ): - """creates class that describes C++ enum declaration + """creates class that describes C++ `enum` declaration The items of the list 'values' may either be strings containing the enumeration value name or tuples (name, numvalue). - :param name: Enum name + :param name: `enum` name :type name: str :param parent: Parent declaration :type parent: declaration_t @@ -75,7 +75,7 @@ @type: list""") def append_value(self, valuename, valuenum=None): - """Append another enumeration value to the enum. + """Append another enumeration value to the `enum`. The numeric value may be None in which case it is automatically determined by increasing the value of the last item. @@ -99,7 +99,7 @@ self._values.append((valuename, int(valuenum))) def has_value_name(self, name): - """Check if this enum has a particular name among its values. + """Check if this `enum` has a particular name among its values. :param name: Enumeration value name :type name: str @@ -111,7 +111,7 @@ return False def get_name2value_dict( self ): - """returns a dictionary, that maps between enum name( key ) and enum value( value )""" + """returns a dictionary, that maps between `enum` name( key ) and `enum` value( value )""" x = {} for val, num in self._values: x[val] = num Modified: pygccxml_dev/pygccxml/declarations/matcher.py =================================================================== --- pygccxml_dev/pygccxml/declarations/matcher.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/matcher.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -32,11 +32,12 @@ @staticmethod def find( decl_matcher, decls, recursive=True ): - """returns a list of declarations that match "decl_matcher" defined criretia or None + """ + returns a list of declarations that match `decl_matcher` defined criteria or None - :param decl_matcher: Python callable object, that takes one argument - reference to declaration - :param decls: reference to declaration or list of declarations to be searched in - :param recursive: boolean, if True the method will run decl_matcher, on internal declarations too + :param decl_matcher: Python callable object, that takes one argument - reference to a declaration + :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t + :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too """ where = [] @@ -50,13 +51,14 @@ @staticmethod def find_single( decl_matcher, decls, recursive=True ): - """returns a reference to declaration, that match "decl_matcher" defined - criretia, if a unique declaration could not be found the method will return - None. + """ + returns a reference to the declaration, that match `decl_matcher` defined criteria. - :param decl_matcher: Python callable object, that takes one argument - reference to declaration - :param decls: reference to declaration or list of declarations to be searched in - :param recursive: boolean, if True the method will run decl_matcher, on internal declarations too + if a unique declaration could not be found the method will return None. + + :param decl_matcher: Python callable object, that takes one argument - reference to a declaration + :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t + :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too """ answer = matcher.find( decl_matcher, decls, recursive ) if len(answer) == 1: @@ -64,13 +66,14 @@ @staticmethod def get_single( decl_matcher, decls, recursive=True ): - """returns a reference to declaration, that match "decl_matcher" defined - criretia, if a unique declaration could not be found, an appropriate - exception will be raised. + """ + returns a reference to declaration, that match `decl_matcher` defined criteria. - :param decl_matcher: Python callable object, that takes one argument - reference to declaration - :param decls: reference to declaration or list of declarations to be searched in - :param recursive: boolean, if True the method will run decl_matcher, on internal declarations too + If a unique declaration could not be found, an appropriate exception will be raised. + + :param decl_matcher: Python callable object, that takes one argument - reference to a declaration + :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t + :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too """ answer = matcher.find( decl_matcher, decls, recursive ) if len(answer) == 1: Modified: pygccxml_dev/pygccxml/declarations/matchers.py =================================================================== --- pygccxml_dev/pygccxml/declarations/matchers.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/matchers.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -110,7 +110,7 @@ """ Instance of this class will match declarations by next criteria: - declaration name, also could be fully qualified name - Example: wstring or ::std::wstring + Example: `wstring` or `::std::wstring` - declaration type Example: :class:`class_t`, :class:`namespace_t`, :class:`enumeration_t` - location within file system ( file or directory ) @@ -491,15 +491,15 @@ class virtuality_type_matcher_t( matcher_base_t ): """ - Instance of this class will match declaration by its virtuality type: not virtual, - virtual or pure virtual. If declarations does not have virtuality type, for example - free function, then False will be returned. + Instance of this class will match declaration by its virtual type: not virtual, + virtual or pure virtual. If declarations does not have "virtual" property, + for example free function, then `False` will be returned. """ def __init__( self, virtuality_type ): """ :param access_type: declaration access type - :type access_type: :class:VIRTUALITY_TYPES defines few consts for your convinience. + :type access_type: :class:VIRTUALITY_TYPES defines few constants for your convenience. """ matcher_base_t.__init__( self ) self.virtuality_type = virtuality_type Modified: pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py =================================================================== --- pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -31,17 +31,26 @@ callable_( *arguments, **keywords ) class mdecl_wrapper_t( object ): - """Multiple declarations wrapper. + """ + multiple declarations class wrapper - The main purpose of this class is to allow an user to work on many - declarations, as they were only one single declaration. + The main purpose of this class is to allow an user to work on many declarations, + as they were only one single declaration. - Example: - mb = module_builder_t( ... ) - #lets say we want to exclude all member functions, that returns reference to int: - mb.member_functions( return_type='int &' ).exclude() + For example, instead of writing `for` loop like the following - "exclude" function will be called on every function that match the criteria. + .. code-block:: python + + for c in global_namespace.classes(): + c.compiler = "GCCXML 1.127" + + you can write: + + .. code-block:: python + + global_namespace.classes().compiler = "GCCXML 1.127" + + The same functionality could be applied on "set" methods too. """ def __init__( self, decls ): @@ -69,7 +78,7 @@ invalid_decls = filter( lambda d: not hasattr( d, name ), self.declarations ) sep = os.linesep + ' ' if invalid_decls: - raise RuntimeError( "Next declarations don't have '%s' attribute: %s" + raise RuntimeError( "Next declarations don't have '%s' attribute: %s" % ( name, sep.join( map( str, invalid_decls ) ) ) ) def __setattr__( self, name, value ): @@ -93,4 +102,4 @@ l = [] for d in self.declarations: l.append( d ) - return l \ No newline at end of file + return l Modified: pygccxml_dev/pygccxml/declarations/namespace.py =================================================================== --- pygccxml_dev/pygccxml/declarations/namespace.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/namespace.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -50,9 +50,9 @@ def adopt_declaration( self, decl ): self.declarations.append( decl ) - decl.parent = self + decl.parent = self decl.cache.reset() - + def remove_declaration( self, decl ): """ removes decl from members list @@ -67,24 +67,24 @@ # decl.parent=None def namespace( self, name=None, function=None, recursive=None ): - """returns reference to namespace declaration, that is matched defined criterias""" + """returns reference to namespace declaration, that is matched defined criteria""" return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.namespace ] , name=name , function=function , recursive=recursive ) ns = namespace - + def namespaces( self, name=None, function=None, recursive=None, allow_empty=None ): - """returns a set of namespace declarations, that are matched defined criterias""" + """returns a set of namespace declarations, that are matched defined criteria""" return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.namespace ] , name=name , function=function , recursive=recursive , allow_empty=allow_empty) nss = namespaces - + def free_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to free function declaration, that is matched defined criterias""" + """returns reference to free function declaration, that is matched defined criteria""" return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.free_function ] , name=name , function=function @@ -95,9 +95,9 @@ , header_file=header_file , recursive=recursive ) free_fun = free_function - + def free_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of free function declarations, that are matched defined criterias""" + """returns a set of free function declarations, that are matched defined criteria""" return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.free_function ] , name=name , function=function @@ -111,7 +111,7 @@ free_funs = free_functions def free_operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to free operator declaration, that is matched defined criterias""" + """returns reference to free operator declaration, that is matched defined criteria""" return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.free_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -124,7 +124,7 @@ , recursive=recursive ) def free_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of free operator declarations, that are matched defined criterias""" + """returns a set of free operator declarations, that are matched defined criteria""" return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.free_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol Modified: pygccxml_dev/pygccxml/declarations/scopedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/scopedef.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/scopedef.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -28,10 +28,10 @@ 1. `name` - declaration name, could be full qualified name - 2. `header_dir` - directory, to which belongs file, that the declaration was declarated in. + 2. `header_dir` - directory, to which belongs file, that the declaration was declared in. `header_dir` should be absolute path. - 3. `header_file` - file that the declaration was declarated in. + 3. `header_file` - file that the declaration was declared in. 4. `function` - user ( your ) custom criteria. The interesting thing is that this function will be joined with other arguments ( criteria ). @@ -40,31 +40,25 @@ internal declarations too. - Every "select" API you can invoke and pass as first argument at declaration - name or function. This class will find out correctly what argument represents. + Every ""query"" API, takes name or function as the first argument. - Example: :: - ns - referrers to global namespace - ns.member_function( "do_something ) - will return reference to member - function named "do_something". If there is no such function exception - will be raised. If there is more then one function exception will be - raised too. + .. code-block:: python - Example 2: :: - ns - referers to global namespace - do_smths = ns.member_functions( "do_something ) - will return instance - of :class:`mdecl_wrapper_t` object. This object allows you few things: + global_namespace.member_function( "do_something ) - 1. To iterate on selected declarations + the statement returns reference to member function named "do_something". + If there the function doesn't exist or more than one function exists, + an exception is raised. - 2. To set some property to desired value using one line of code only: - do_smths.call_policies = x + If you want to query for many declarations, use other function(s): - 3. To call some function on every instance using one line of code: - do_smths.exclude() + .. code-block:: python + do_something = global_namespace.member_functions( "do_something ) - Pay attention: you can not use "get" functions or properties. + the statement returns :class:`mdecl_wrapper_t` instance. That object will save + you writing `for` loops. For more information see :class:`the class <mdecl_wrapper_t>` + documentation. """ RECURSIVE_DEFAULT = True @@ -168,7 +162,9 @@ , self.declarations ) ) def init_optimizer(self): - """Initializes query optimizer state. + """ + Initializes query optimizer state. + There are 4 internals hash tables: 1. from type to declarations 2. from type to declarations for non-recursive queries @@ -177,7 +173,7 @@ Almost every query includes declaration type information. Also very common query is to search some declaration(s) by name or full name. - Those hashtables allows to search declaration very quick. + Those hash tables allows to search declaration very quick. """ if self.name == '::': self._logger.debug( "preparing data structures for query optimizer - started" ) @@ -382,7 +378,7 @@ return mfound def decl( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to declaration, that is matched defined criterias""" + """returns reference to declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.decl ] , name=name , function=function @@ -392,7 +388,7 @@ , recursive=recursive) def decls( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of declarations, that are matched defined criterias""" + """returns a set of declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.decl ] , name=name , function=function @@ -403,7 +399,7 @@ , allow_empty=allow_empty) def class_( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to class declaration, that is matched defined criterias""" + """returns reference to class declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.class_ ] , name=name , function=function @@ -413,7 +409,7 @@ , recursive=recursive) def classes( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of class declarations, that are matched defined criterias""" + """returns a set of class declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.class_ ] , name=name , function=function @@ -424,7 +420,7 @@ , allow_empty=allow_empty) def variable( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to variable declaration, that is matched defined criterias""" + """returns reference to variable declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.variable ] , name=name , function=function @@ -435,7 +431,7 @@ var = variable #small alias def variables( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of variable declarations, that are matched defined criterias""" + """returns a set of variable declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.variable ] , name=name , function=function @@ -447,7 +443,7 @@ vars = variables #small alias def calldef( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to "calldef" declaration, that is matched defined criterias""" + """returns reference to "calldef" declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.calldef ] , name=name , function=function @@ -459,7 +455,7 @@ , recursive=recursive ) def calldefs( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of calldef declarations, that are matched defined criterias""" + """returns a set of calldef declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.calldef ] , name=name , function=function @@ -472,7 +468,7 @@ , allow_empty=allow_empty) def operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to operator declaration, that is matched defined criterias""" + """returns reference to operator declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -485,7 +481,7 @@ , recursive=recursive ) def operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of operator declarations, that are matched defined criterias""" + """returns a set of operator declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -499,7 +495,7 @@ , allow_empty=allow_empty) def member_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to member declaration, that is matched defined criterias""" + """returns reference to member declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.member_function ] , name=name , function=function @@ -512,7 +508,7 @@ mem_fun = member_function def member_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of member function declarations, that are matched defined criterias""" + """returns a set of member function declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.member_function ] , name=name , function=function @@ -526,7 +522,7 @@ mem_funs = member_functions def constructor( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to constructor declaration, that is matched defined criterias""" + """returns reference to constructor declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.constructor ] , name=name , function=function @@ -538,7 +534,7 @@ , recursive=recursive ) def constructors( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of constructor declarations, that are matched defined criterias""" + """returns a set of constructor declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.constructor ] , name=name , function=function @@ -551,7 +547,7 @@ , allow_empty=allow_empty) def member_operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to member operator declaration, that is matched defined criterias""" + """returns reference to member operator declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.member_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -564,7 +560,7 @@ , recursive=recursive ) mem_oper = member_operator def member_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of member operator declarations, that are matched defined criterias""" + """returns a set of member operator declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.member_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -579,7 +575,7 @@ mem_opers = member_operators def casting_operator( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to casting operator declaration, that is matched defined criterias""" + """returns reference to casting operator declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.casting_operator ] , name=name , function=function @@ -591,7 +587,7 @@ , recursive=recursive ) def casting_operators( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of casting operator declarations, that are matched defined criterias""" + """returns a set of casting operator declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.casting_operator ] , name=name , function=function @@ -604,7 +600,7 @@ , allow_empty=allow_empty) def enumeration( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to enumeration declaration, that is matched defined criterias""" + """returns reference to enumeration declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.enumeration ] , name=name , function=function @@ -617,7 +613,7 @@ """adding small aliase to enumeration method""" def enumerations( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of enumeration declarations, that are matched defined criterias""" + """returns a set of enumeration declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.enumeration ] , name=name , function=function @@ -630,7 +626,7 @@ enums = enumerations def typedef( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to typedef declaration, that is matched defined criterias""" + """returns reference to typedef declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.typedef ] , name=name , function=function @@ -640,7 +636,7 @@ , recursive=recursive) def typedefs( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of typedef declarations, that are matched defined criterias""" + """returns a set of typedef declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.typedef ] , name=name , function=function @@ -651,9 +647,10 @@ , allow_empty=allow_empty) def __getitem__(self, name_or_function): - """ Allow simple name based find of decls. Internally just calls decls() method. - :param name_or_function Name of decl to lookup or finder function. """ + Allow simple name based find of declarations. Internally just calls `decls` method. + :param name_or_function: Name of `decl` to lookup or finder function. + """ return self.decls(name_or_function) Modified: pygccxml_dev/pygccxml/declarations/templates.py =================================================================== --- pygccxml_dev/pygccxml/declarations/templates.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/templates.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -3,11 +3,11 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -""" +""" template instantiation parser This module implements all functionality necessary to parse C++ template -instantiations.In other words this module is able to extract next information from +instantiations.In other words this module is able to extract next information from the string like this C{ std::vector<int> }. - name ( std::vector ) - list of arguments ( int ) @@ -21,11 +21,11 @@ def is_instantiation( decl_string ): """ - returns True if decl_string is template instantiation and False otherwise - + returns True if `decl_string` is template instantiation and False otherwise + :param decl_string: string that should be checked for pattern presence :type decl_string: str - + :rtype: bool """ global __THE_PARSER @@ -34,7 +34,7 @@ def name( decl_string ): """ returns name of instantiated template - + :type decl_string: str :rtype: str """ @@ -44,18 +44,18 @@ def args( decl_string ): """ returns list of template arguments - - :type decl_string: str - :rtype: [str] + + :type decl_string: `str` + :rtype: [`str`] """ global __THE_PARSER return __THE_PARSER.args( decl_string ) - + def split( decl_string ): """returns (name, [arguments] )""" global __THE_PARSER return __THE_PARSER.split( decl_string ) - + def split_recursive( decl_string ): """returns [(name, [arguments])]""" global __THE_PARSER @@ -67,8 +67,8 @@ return __THE_PARSER.join( name, args ) def normalize( decl_string ): - """returns decl_string, which contains "normalized" spaces - + """returns `decl_string`, which contains "normalized" spaces + this functionality allows to implement comparison of 2 different string which are actually same: x::y< z > and x::y<z> """ Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/utils/__init__.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -4,7 +4,7 @@ # http://www.boost.org/LICENSE_1_0.txt) """ -defines logger classes and few convinience methods, not related to the declarations +defines logger classes and few convenience methods, not related to the declarations tree """ @@ -59,7 +59,7 @@ """ root = logging.getLogger( 'pygccxml' ) - """root logger exists for your convinience only""" + """root logger exists for your convenience only""" all = [ root, cxx_parser, queries_engine, declarations_cache, pdb_reader ] """contains all logger classes, defined by the class""" @@ -74,7 +74,7 @@ % ( file_name, str( error ) ) ) def create_temp_file_name(suffix, prefix=None, dir=None): - """small convinience function that creates temporal file. + """small convenience function that creates temporal file. This function is a wrapper aroung Python built-in function - tempfile.mkstemp """ Modified: pygccxml_dev/unittests/autoconfig.py =================================================================== --- pygccxml_dev/unittests/autoconfig.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/unittests/autoconfig.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -15,8 +15,11 @@ this_module_dir_path = os.path.abspath ( os.path.dirname( sys.modules[__name__].__file__) ) sys.path.append( os.path.abspath( os.path.join( this_module_dir_path, '..', '..', 'pydsc_dev' ) ) ) -#~ import pydsc +import pydsc +pydsc.ignore_dictionary( 'ignore_dictionary.txt' ) +pydsc.set_text_preprocessor( pydsc.sphinx_preprocessor ) +pydsc.include_paths( os.path.join( this_module_dir_path, '..', '..', 'pygccxml_dev' ) ) data_directory = os.path.join( this_module_dir_path, 'data' ) build_directory = os.path.join( this_module_dir_path, 'temp' ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |