From 419d28b175e39a4cee7f0533e4577837bce054b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylvain=20Th=C3=A9nault?= Date: Tue, 18 Jun 2013 18:19:18 +0200 Subject: start some documentation for the new transformation API --- doc/extending.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 doc/extending.rst (limited to 'doc') diff --git a/doc/extending.rst b/doc/extending.rst new file mode 100644 index 00000000..da3b4e6a --- /dev/null +++ b/doc/extending.rst @@ -0,0 +1,28 @@ +Extending Astroid Syntax Tree +============================= + +Sometimes Astroid will miss some potentially important information you may wish +you add, as content of the standard library `hashlib` module. In some other +cases, you may want to customize the way inference work, for instance to explain +Astroid that `collections.namedtuple` is returning a class with some known +attributes. + +The good news is that you can do it using the transformation API. You'll find +examples in the `brain/` subdirectory. Those come from the `pylint-brain`_ project. + +Transformation functions are registered using the `register_transform` method of +the Astroid manager: + +.. automethod:: astroid.manager.AstroidManager.register_transform + +You may want to use :class:`astroid.AsStringRegexpPredicate` predicate objects +to filter on the `as_string` representation of the node. + +.. autoclass:: astroid.AsStringRegexpPredicate + +Last but not least, the :func:`inference_tip` function is there to register +custom inference function. + +.. autofunction:: astroid.inference_tip + +.. _`pylint-brain`: https://bitbucket.org/logilab/pylint-brain \ No newline at end of file -- cgit v1.2.1