pydsc introduction

What is pydsc?

pydsc - PYthon Documentation string Spell Checker

What it is useful for?

The pydsc module checks documentation strings and comments for spelling errors.

Usage example

It is very easy to start using pydsc module - just import it:

import pydsc

and every module, that will be imported after it, in the current working directory will be checked. The errors will be printed to stdout.

pydsc contains few functions, which helps you to configure the spell checker:
  • to define your own “ignore” dictionary
  • to define the error messages destination (file, stdout)
  • to define set of files, which should be checked
  • to ignore Sphinx specific words and code blocks

For more information see pydsc module.

Spell engine

pydsc modules uses PyEnchant one.

The PyEnchant package provides interface for different spell engines:
  • ispell
  • aspell
  • OpenOffice

Installation

python setup.py install

API

The pydsc module checks documentation strings and comments for spelling errors.

Usage example:

import pydsc
pydsc.include_paths( r'D:\pygccxml_dev\pygccxml' ) #check only pygccxml package
pydsc.ignore_words([ 'Yakovenko', 'www', 'org', 'py' ])
#if you use sphinx as a documentation tool:
pydsc.set_text_preprocessor( pydsc.sphinx_preprocessor )
class pydsc.checker_t(speller, writer=<open file '<stdout>', mode 'w' at 0xb7ed2070>, ignore_identifiers=True, text_preprocessor=<function <lambda> at 0x9becd4c>)

Applies spell check process on every imported module.

Every documentation string within the imported modules will be checked. Some comments will be checked too. The inspect module is used to extract documentation strings and comments

initialization method

replaces __builtin__.__import__() function with checker_t.import_()

Parameters:
  • speller (enchant.checker.SpellChecker) – reference to enchant.checker.SpellChecker object
  • writer – reference to instance of class that has write method. By default sys.stdout will be used.
  • ignore_identifiers (bool) – often comments/documentation strings contains classmethodfunction names. Those names, usually introduce spell error. If ignore_identifiers set to True, those names will be ignored.
  • 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.
add_include_paths(path)
static getsourcefile(obj)
import_(name, globals=None, locals=None, fromlist=None, level=-1)
Hook to import functionality
report_statistics()
should_be_checked(obj, module=None)
returns True, if obj should be checked, False otherwise
pydsc.contains_parent_dir(path, dirs)

returns true if one of the directories is root directory for the path, false otherwise

Parameters:
  • path (str) – path to be checked
  • dirs ([ str ]) – list of directories andor files
Return type:

bool

pydsc.ignore_dictionary(path, case_sensitive=False)

adds all words from file to the “ignore” list

The file should contain one word per line

Parameter:path (str) – path to dictionary file
pydsc.ignore_words(what, case_sensitive=False)

adds what, word or list of words, to the ignore list.

what - word(string) or list of words(strings) to be ignored.

pydsc.include_paths(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

pydsc.is_identifier(word)

returns True is the word represents an identifier, constructed from two or more words, False otherwise.

This function is used to filter out some errors, reported by spell checker.

pydsc.normalize_path(some_path)
return os.path.normcase( os.path.normpath( some_path ) )
pydsc.set_text_preprocessor(preprocessor)
class pydsc.sphinx_preprocessor_t

Table Of Contents

Previous topic

C\C++ Python language binding

Next topic

pygccxml package

This Page