From e98ac74737c1f28ec730fa5c645062e0e0d5702b Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Wed, 27 Aug 2014 14:59:40 -0400 Subject: Allow named extensions to specify the Class Name If you were to import the class like this: from path.to.module import SomeExtensionClass Then the named extension would be the string: "path.to.module:SomeExtensionClass" This should simplify loading extensions from the command line or template filters -- expecially when multiple extensions are defined in a single python module. The docs still need updating. I'm waiting to update the docs after implementing #335 and #336 as that will require a major refactor of that section of the docs anyway. --- docs/release-2.5.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'docs') diff --git a/docs/release-2.5.txt b/docs/release-2.5.txt index eb9c44c..ea351b0 100644 --- a/docs/release-2.5.txt +++ b/docs/release-2.5.txt @@ -36,6 +36,36 @@ languages other than English. Thanks to [Martin Altmayer] for implementing this [Smarty Extension]: extensions/smarty.html [Martin Altmayer]:https://github.com/MartinAltmayer +* Named Extensions (strings passed to the [`extensions`][ex] keyword of `markdown.Markdown`) + can now point to any module and/or Class on your PYTHONPATH. While dot notation was + previously supported, a module could not be at the root of your PYTHONPATH. The name had + to contain at least one dot (requiring it to be a submodule). This restriction no longer + exists. + + Additionaly, a Class may be specified in the name. The class must be at the end of the + name (usig dot notation from PYTHONPATH) and seperated by a colon from the module. + + Therefore, if you were to import the class like this: + + from path.to.module import SomeExtensionClass + + Then the named extension would be the string: + + "path.to.module:SomeExtensionClass" + + This allows multiple extensions to be implemented within the same module and still + accessable when the user isn't able to import the extension directly (perhaps from + a template filter or the command line). + + This also means that extension modules are no longer required to include the + `makeExtension` funtion which returns an instance of the extension class. However, + if the user does not specify the class name (she only provides `"path.to.module"`) + the extension will fail to load without the `makeExtension` function included in + the module. Extension authors will want to document carfully what is required to + load their extensions. + +[ex]: reference.html#extensions + * The Extension Configuration code has been refactord to make it a little easier for extension authors to work with config settings. As a result, the [`extension_configs`][ec] keyword now accepts a dictionary rather than requiring -- cgit v1.2.3