Package epydoc :: Package docwriter :: Module xlink :: Class DocUrlGenerator
[hide private]
[frames] | no frames]

ClassType DocUrlGenerator

source code


Read a documentation index and generate URL's for it.
Nested Classes [hide private]

Inherited from UrlGenerator: IndexAmbiguous

Instance Methods [hide private]
 
__init__(self) source code
str
get_url(self, name)
Look for a name and return the matching URL documentation.
source code

Inherited from UrlGenerator: get_canonical_name

    Content loading
 
clear(self)
Clear the current class content.
source code
 
load_index(self, f)
Read the content of an index file.
source code
 
_iter_tuples(self, f)
Iterate on a file returning 2-tuples.
source code
 
load_records(self, records)
Read a sequence of pairs name -> url and populate the internal maps.
source code
Class Variables [hide private]

Inherited from UrlGenerator (private): _SEP_RE

Instance Variables [hide private]
  _exact_matches
A map from an object fully qualified name to its URL.
  _partial_names
A map from partial names to the fully qualified names they may refer.
  prefix
Prefix portion for the URL's returned by get\_url().
  _filename
Not very important: only for logging.
Method Details [hide private]

get_url(self, name)

source code 

Look for a name and return the matching URL documentation.

First look for a fully qualified name. If not found, try with partial name.

If no url exists for the given object, return None.

Parameters:
  • name - the name to look for
Returns: str
the URL that can be used to reach the name documentation. None if no such URL exists.
Raises:
  • IndexError - no object found with name
  • DocUrlGenerator.IndexAmbiguous - more than one object found with a non-fully qualified name; notice that this is an IndexError subclass
Overrides: UrlGenerator.get_url
(inherited documentation)

load_index(self, f)

source code 

Read the content of an index file.

Populate the internal maps with the file content using load\_records().

Parameters:
  • f (str or file) - a file name or file-like object fron which read the index.

load_records(self, records)

source code 
Read a sequence of pairs name -> url and populate the internal maps.
Parameters:
  • records (iterable) - the sequence of pairs (name, url) to add to the maps.

Instance Variable Details [hide private]

_exact_matches

A map from an object fully qualified name to its URL.

Values are both the name as tuple of fragments and as read from the records (see load\_records()), mostly to help \_partial\_names to perform lookup for unambiguous names.

_partial_names

A map from partial names to the fully qualified names they may refer.

The keys are the possible left sub-tuples of fully qualified names, the values are list of strings as provided by the index.

If the list for a given tuple contains a single item, the partial match is not ambuguous. In this case the string can be looked up in \_exact\_matches.

If the name fragment is ambiguous, a warning may be issued to the user. The items can be used to provide an informative message to the user, to help him qualifying the name in a unambiguous manner.