Skip to content

Commit

Permalink
Run pep8 and pylint in test target, clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
djungelorm committed Jan 22, 2017
1 parent d163d86 commit 4dddfcb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ install:

test:
rm -rf out
pep8 sphinx_tabs/tabs.py
pip install pylint
pylint --rcfile=pylint.cfg sphinx_tabs/tabs.py
sphinx-build -E -n -W test test-output

clean:
Expand Down
2 changes: 2 additions & 0 deletions pylint.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[REPORTS]
reports=no
15 changes: 13 additions & 2 deletions sphinx_tabs/tabs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
""" Tabbed views for Sphinx, with HTML builder """

import os
from docutils.parsers.rst import Directive
from docutils import nodes
Expand All @@ -11,9 +13,12 @@


class TabsDirective(Directive):
""" Top-level tabs directive """

has_content = True

def run(self):
""" Parse a tabs directive """
self.assert_has_content()
env = self.state.document.settings.env

Expand All @@ -40,9 +45,12 @@ def run(self):


class TabDirective(Directive):
""" Tab directive, for adding a tab to a collection of tabs """

has_content = True

def run(self):
""" Parse a tab directive """
env = self.state.document.settings.env
self.assert_has_content()
text = '\n'.join(self.content)
Expand All @@ -59,6 +67,7 @@ def run(self):


def add_assets(app):
""" Add CSS and JS asset files """
for path in FILES:
if '.css' in path:
app.add_stylesheet(path)
Expand All @@ -67,6 +76,7 @@ def add_assets(app):


def copy_assets(app, exception):
""" Copy asset files to the output """
if app.builder.name != 'html' or exception:
return
app.info('Copying tabs assets... ', nonl=True)
Expand All @@ -78,7 +88,8 @@ def copy_assets(app, exception):


def setup(app):
app.add_directive('tabs', TabsDirective)
app.add_directive('tab', TabDirective)
""" Set up the plugin """
app.add_directive('tabs', TabsDirective)
app.add_directive('tab', TabDirective)
app.connect('builder-inited', add_assets)
app.connect('build-finished', copy_assets)

0 comments on commit 4dddfcb

Please sign in to comment.