Skip to content

Commit

Permalink
Follow advice of #22
Browse files Browse the repository at this point in the history
  • Loading branch information
takuan-osho committed Jan 13, 2019
1 parent 2b02cf1 commit 998730a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
4 changes: 4 additions & 0 deletions sphinxcontrib/websupport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
:copyright: Copyright 2007-2018 by the Sphinx team, see README.
:license: BSD, see LICENSE for details.
"""
from os import path

__import__('pkg_resources').declare_namespace(__name__)

from sphinxcontrib.websupport.core import WebSupport # NOQA
from sphinxcontrib.websupport.version import __version__, __version_info__ # NOQA


package_dir = package_dir = path.abspath(path.dirname(__file__))
28 changes: 16 additions & 12 deletions sphinxcontrib/websupport/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from sphinx.util.osutil import os_path, relative_uri, ensuredir, copyfile
from sphinx.builders.html import PickleHTMLBuilder

from . import package_dir
from .writer import WebSupportTranslator


Expand All @@ -28,6 +29,17 @@
from docutils import nodes # NOQA
from sphinx.application import Sphinx # NOQA

RESOURCES = [
'ajax-loader.gif',
'comment-bright.png',
'comment-close.png',
'comment.png',
'down-pressed.png',
'down.png',
'up-pressed.png',
'up.png',
]


class WebSupportBuilder(PickleHTMLBuilder):
"""
Expand Down Expand Up @@ -177,23 +189,15 @@ def handle_finish(self):
if path.isdir(dst):
shutil.rmtree(dst)
shutil.move(src, dst)
self.copy_resources()

def copy_resources(self):
# type: () -> None
# copy resource files to static dir
resources = [
'ajax-loader.gif',
'comment-bright.png',
'comment-close.png',
'comment.png',
'down-pressed.png',
'down.png',
'up-pressed.png',
'up.png',
]
package_dir = path.abspath(path.dirname(__file__))
dst = path.join(self.staticdir, '_static')

if path.isdir(dst):
for resource in resources:
for resource in RESOURCES:
src = path.join(package_dir, 'files', resource)
shutil.copy(src, dst)

Expand Down

0 comments on commit 998730a

Please sign in to comment.