Skip to content

Commit

Permalink
Add ShortcodePlugin class
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Aug 2, 2016
1 parent 141ea96 commit 82e03af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/extending.txt
Expand Up @@ -577,7 +577,7 @@ So, if you are creating a plugin that generates markup, it may be a good idea
to register it as a shortcode in addition of to restructured text directive or
markdown extension, thus making it available to all markup formats.

To implement your own shortcodes from a plugin, you can call
To implement your own shortcodes from a plugin, you can create a plugin inheriting ``ShortcodePlugin`` and call
``Nikola.register_shortcode(name, func)`` with the following arguments:

``name``:
Expand Down
5 changes: 5 additions & 0 deletions nikola/nikola.py
Expand Up @@ -66,6 +66,7 @@
CompilerExtension,
MarkdownExtension,
RestExtension,
ShortcodePlugin,
Task,
TaskMultiplier,
TemplateSystem,
Expand Down Expand Up @@ -892,6 +893,7 @@ def init_plugins(self, commands_only=False, load_all=False):
"CompilerExtension": CompilerExtension,
"MarkdownExtension": MarkdownExtension,
"RestExtension": RestExtension,
"ShortcodePlugin": ShortcodePlugin,
"SignalHandler": SignalHandler,
"ConfigPlugin": ConfigPlugin,
"PostScanner": PostScanner,
Expand Down Expand Up @@ -990,6 +992,9 @@ def plugin_position_in_places(plugin):
self.plugin_manager.activatePluginByName(plugin_info.name)
plugin_info.plugin_object.set_site(self)

# Activate shortcode plugins
self._activate_plugins_of_category("ShortcodePlugin")

# Load compiler plugins
self.compilers = {}
self.inverse_compilers = {}
Expand Down
6 changes: 6 additions & 0 deletions nikola/plugin_categories.py
Expand Up @@ -344,6 +344,12 @@ class ConfigPlugin(BasePlugin):
name = "dummy_config_plugin"


class ShortcodePlugin(BasePlugin):
"""A plugin that adds a shortcode."""

name = "dummy_shortcode_plugin"


class Importer(Command):
"""Basic structure for importing data into Nikola.
Expand Down

0 comments on commit 82e03af

Please sign in to comment.