Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Add options to sphinx directive (#40)
Browse files Browse the repository at this point in the history
* Add output format to option spec

* Update output format

* Add output format option

* Set default option for output format

* Try different default

* Set a default for the output format option
  • Loading branch information
edwardtheharris authored Feb 2, 2022
1 parent cbaafd6 commit 29427db
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frigate/sphinx/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@

from docutils import nodes
from docutils.parsers import rst
from docutils.parsers.rst.directives import unchanged
from docutils.statemachine import ViewList
from sphinx.util.nodes import nested_parse_with_titles

from frigate.gen import gen


class FrigateDirective(rst.Directive):
has_content = False
has_content = True
required_arguments = 1
option_spec = {
'output_format': unchanged,
}

def run(self):
chart_path = os.path.join(
os.getcwd(), # TODO Need to find a better way to get the root of the docs
self.arguments[0],
)
output = ViewList(gen(chart_path, output_format="rst").split("\n"))
if self.options.get('output_format') is None:
self.options.update({'output_format': 'rst'})
output = ViewList(gen(chart_path, output_format=self.options.get('output_format')).split("\n"))

node = nodes.section()
node.document = self.state.document
Expand Down

0 comments on commit 29427db

Please sign in to comment.