Skip to content
Snippets Groups Projects
Commit b6b07751 authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony
Browse files

Hard code section header names rather than using the module titles

It's clearer where the section names come from and avoids any unwanted
module qualifications when the directives become part of a package.
Refs #9521
parent 48610385
No related merge requests found
"""
Defines custom directives for Mantid documentation
Each directive should be defined in a different module and have its own
setup(app) function. The setup function defined here is used to tie them
all together in the case where all directives are required, allowing
'mantiddoc.directives' to be added to the Sphinx extensions configuration.
"""
import algorithm, aliases, categories, properties, summary
def setup(app):
"""
Setup the directives when the extension is activated
Args:
app: The main Sphinx application object
"""
algorithm.setup(app)
aliases.setup(app)
categories.setup(app)
properties.setup(app)
summary.setup(app)
from base import BaseDirective from base import BaseDirective
class AlgorithmDirective(BaseDirective): class AlgorithmDirective(BaseDirective):
""" """
...@@ -56,5 +55,11 @@ class AlgorithmDirective(BaseDirective): ...@@ -56,5 +55,11 @@ class AlgorithmDirective(BaseDirective):
def setup(app): def setup(app):
"""
Setup the directives when the extension is activated
Args:
app: The main Sphinx application object
"""
app.add_config_value('mantid_images', 'mantid_images', 'env') app.add_config_value('mantid_images', 'mantid_images', 'env')
app.add_directive('algorithm', AlgorithmDirective) app.add_directive('algorithm', AlgorithmDirective)
...@@ -13,7 +13,7 @@ class AliasesDirective(BaseDirective): ...@@ -13,7 +13,7 @@ class AliasesDirective(BaseDirective):
""" """
Called by Sphinx when the ..aliases:: directive is encountered. Called by Sphinx when the ..aliases:: directive is encountered.
""" """
title = self._make_header(__name__.title()) title = self._make_header("Aliases")
alias = self._get_alias(str(self.arguments[0])) alias = self._get_alias(str(self.arguments[0]))
return self._insert_rest(title + alias) return self._insert_rest(title + alias)
...@@ -29,4 +29,10 @@ class AliasesDirective(BaseDirective): ...@@ -29,4 +29,10 @@ class AliasesDirective(BaseDirective):
def setup(app): def setup(app):
"""
Setup the directives when the extension is activated
Args:
app: The main Sphinx application object
"""
app.add_directive('aliases', AliasesDirective) app.add_directive('aliases', AliasesDirective)
...@@ -14,7 +14,7 @@ class CategoriesDirective(BaseDirective): ...@@ -14,7 +14,7 @@ class CategoriesDirective(BaseDirective):
Called by Sphinx when the ..categories:: directive is encountered. Called by Sphinx when the ..categories:: directive is encountered.
""" """
categories = self._get_categories(str(self.arguments[0])) categories = self._get_categories(str(self.arguments[0]))
return self._insert_rest(categories) return self._insert_rest("\n" + categories)
def _get_categories(self, algorithm_name): def _get_categories(self, algorithm_name):
""" """
...@@ -38,4 +38,10 @@ class CategoriesDirective(BaseDirective): ...@@ -38,4 +38,10 @@ class CategoriesDirective(BaseDirective):
def setup(app): def setup(app):
"""
Setup the directives when the extension is activated
Args:
app: The main Sphinx application object
"""
app.add_directive('categories', CategoriesDirective) app.add_directive('categories', CategoriesDirective)
...@@ -14,7 +14,7 @@ class PropertiesDirective(BaseDirective): ...@@ -14,7 +14,7 @@ class PropertiesDirective(BaseDirective):
Called by Sphinx when the ..properties:: directive is encountered. Called by Sphinx when the ..properties:: directive is encountered.
""" """
alg_name = str(self.arguments[0]) alg_name = str(self.arguments[0])
title = self._make_header(__name__.title()) title = self._make_header("Properties")
properties_table = self._populate_properties_table(alg_name) properties_table = self._populate_properties_table(alg_name)
return self._insert_rest(title + properties_table) return self._insert_rest(title + properties_table)
...@@ -156,4 +156,10 @@ class PropertiesDirective(BaseDirective): ...@@ -156,4 +156,10 @@ class PropertiesDirective(BaseDirective):
def setup(app): def setup(app):
"""
Setup the directives when the extension is activated
Args:
app: The main Sphinx application object
"""
app.add_directive('properties', PropertiesDirective) app.add_directive('properties', PropertiesDirective)
...@@ -13,7 +13,7 @@ class SummaryDirective(BaseDirective): ...@@ -13,7 +13,7 @@ class SummaryDirective(BaseDirective):
""" """
Called by Sphinx when the ..summary:: directive is encountered. Called by Sphinx when the ..summary:: directive is encountered.
""" """
title = self._make_header(__name__.title()) title = self._make_header("Summary")
summary = self._get_summary(str(self.arguments[0])) summary = self._get_summary(str(self.arguments[0]))
return self._insert_rest(title + summary) return self._insert_rest(title + summary)
...@@ -29,4 +29,10 @@ class SummaryDirective(BaseDirective): ...@@ -29,4 +29,10 @@ class SummaryDirective(BaseDirective):
def setup(app): def setup(app):
"""
Setup the directives when the extension is activated
Args:
app: The main Sphinx application object
"""
app.add_directive('summary', SummaryDirective) app.add_directive('summary', SummaryDirective)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment