Skip to content

Commit

Permalink
chore: Merge pull request #114 from attakei/issue/104
Browse files Browse the repository at this point in the history
Remove func for generating needless pages

Refs: #104
  • Loading branch information
attakei authored May 23, 2022
2 parents 98bc0e9 + 2f046a3 commit 40d22a1
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES-2.x.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ Added Features
--------------

* Directive ``revealjs-notes`` writes speaker-view content into presentation

* Config ``reveajs_notes_from_comments`` toggle if it creates speaker-view content from comment-block

* BREAKING CHANGE: Default value is False. You must set ``True`` explicitly to use as same as ver 1.x
* Config ``reveajs_use_index`` toggle if it creates ``genindex.html``

* BREAKING CHANGE: Default value is False. You must set ``True`` explicitly to use as same as ver 1.x

Deleted feaures
---------------

* Remove snake-cesed directives
* Does not generate ``search.html``
7 changes: 7 additions & 0 deletions doc/configurations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ Basic configurations

If you want to customize presentation by CSS, write external css and use it.

.. confval:: revealjs_use_index

:Type: ``bool``
:Default: ``False``

Flag that does builder generate ``genindex.html`` (same as :confval:`sphinx:html_use_index` ).

Style Configurations
====================

Expand Down
6 changes: 6 additions & 0 deletions doc/upgrade/2.x.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ You must do one of these.
* Copy needy values of ``html_js_files`` to ``revealjs_js_files``
* Sync ``html_js_files`` to ``revealjs_js_files`` (ex: ``revealjs_js_files = html_js_files``)

revealjs_use_index
------------------

|THIS| does not generate ``genindex.html`` (list of in vals) on default.
If you want ``genindex.html`` for Reveal.js builder, you muse set ``True``.

Directives
==========

Expand Down
1 change: 1 addition & 0 deletions sphinx_revealjs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def setup(app: Sphinx):
app.add_directive("revealjs-fragments", RevealjsFragments)
app.add_directive("revealjs-code-block", RevealjsCodeBlock)
app.add_config_value("revealjs_use_section_ids", False, True)
app.add_config_value("revealjs_use_index", False, "env")
app.add_config_value("revealjs_static_path", [], True)
app.add_config_value("revealjs_style_theme", "black", True)
app.add_config_value("revealjs_js_files", [], True)
Expand Down
2 changes: 2 additions & 0 deletions sphinx_revealjs/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class RevealjsHTMLBuilder(StandaloneHTMLBuilder):

name = "revealjs"
default_translator_class = RevealjsSlideTranslator
search = False

def __init__(self, app): # noqa: D107
super().__init__(app)
Expand All @@ -52,6 +53,7 @@ def init(self): # noqa
# Hand over builder configs to html builder.
setattr(self.config, "html_static_path", self.config.revealjs_static_path)
super().init()
self.use_index = self.get_builder_config("use_index", "revealjs")

def init_css_files(self) -> None: # noqa
self.add_css_file(self.revealjs_context.engine.css_path)
Expand Down
5 changes: 5 additions & 0 deletions tests/roots/test-default/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
extensions = [
"sphinx_revealjs",
]

# To skip toctree
rst_prolog = """
:orphan:
"""
5 changes: 5 additions & 0 deletions tests/roots/test-for-commented-notes/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
extensions = [
"sphinx_revealjs",
]

# To skip toctree
rst_prolog = """
:orphan:
"""
5 changes: 5 additions & 0 deletions tests/roots/test-for-config/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
extensions = [
"sphinx_revealjs",
]

# To skip toctree
rst_prolog = """
:orphan:
"""
11 changes: 11 additions & 0 deletions tests/test_configurations/test_generatings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Test cases for generating giles."""
import pytest
from sphinx.testing.util import SphinxTestApp


@pytest.mark.sphinx(
"revealjs", testroot="default", confoverrides={"revealjs_use_index": True}
)
def test_generating_genindex(app: SphinxTestApp, status, warning): # noqa
app.build()
assert (app.outdir / "genindex.html").exists()
15 changes: 15 additions & 0 deletions tests/test_generatings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Test cases for generating giles."""
import pytest
from sphinx.testing.util import SphinxTestApp


@pytest.mark.sphinx("revealjs", testroot="default")
def test_not_generate_genindex(app: SphinxTestApp, status, warning): # noqa
app.build()
assert not (app.outdir / "genindex.html").exists()


@pytest.mark.sphinx("revealjs", testroot="default")
def test_not_generate_search(app: SphinxTestApp, status, warning): # noqa
app.build()
assert not (app.outdir / "search.html").exists()

0 comments on commit 40d22a1

Please sign in to comment.