Skip to content

Commit

Permalink
Added the possibility to specify the destination directory in autogen…
Browse files Browse the repository at this point in the history
….py (#12220)

* Added the possibility to specify the destination directory.

* Running the docs tests only in one build.
  • Loading branch information
gabrieldemarmiesse authored and fchollet committed Feb 7, 2019
1 parent c55ce21 commit 74ccfc4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ script:
- if [[ "$TEST_MODE" == "INTEGRATION_TESTS" ]]; then
PYTHONPATH=$PWD:$PYTHONPATH py.test tests/integration_tests;
elif [[ "$TEST_MODE" == "PEP8_DOC" ]]; then
PYTHONPATH=$PWD:$PYTHONPATH py.test --pep8 -m pep8 -n0 && py.test tests/test_documentation.py && cd docs && python autogen.py && mkdocs build;
PYTHONPATH=$PWD:$PYTHONPATH py.test --pep8 -m pep8 -n0 && py.test tests/test_documentation.py tests/test_doc_auto_generation.py;
else
PYTHONPATH=$PWD:$PYTHONPATH py.test tests/ --ignore=tests/integration_tests --ignore=tests/test_documentation.py --ignore=tests/keras/legacy/layers_test.py --cov-config .coveragerc --cov=keras tests/;
PYTHONPATH=$PWD:$PYTHONPATH py.test tests/ --ignore=tests/integration_tests --ignore=tests/test_documentation.py --ignore=tests/test_doc_auto_generation.py --ignore=tests/keras/legacy/layers_test.py --cov-config .coveragerc --cov=keras tests/;
fi
10 changes: 7 additions & 3 deletions docs/autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,12 @@ def copy_examples(examples_dir, destination_dir):
f_out.write('```')


def generate():
sources_dir = os.path.join(keras_dir, 'docs', 'sources')
def generate(sources_dir):
"""Generates the markdown files for the documentation.
# Arguments
sources_dir: Where to put the markdown files.
"""
template_dir = os.path.join(keras_dir, 'docs', 'templates')

if K.backend() != 'tensorflow':
Expand Down Expand Up @@ -464,4 +468,4 @@ def generate():


if __name__ == '__main__':
generate()
generate(os.path.join(keras_dir, 'docs', 'sources'))
9 changes: 9 additions & 0 deletions tests/test_doc_auto_generation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from markdown import markdown
from docs import autogen
import pytest
Expand Down Expand Up @@ -386,5 +387,13 @@ def test_doc_multiple_sections_code():
assert 'def dot(x, y):' in generated


def test_docs_in_custom_destination_dir(tmpdir):
autogen.generate(tmpdir)
assert os.path.isdir(os.path.join(tmpdir, 'layers'))
assert os.path.isdir(os.path.join(tmpdir, 'models'))
assert os.path.isdir(os.path.join(tmpdir, 'examples'))
assert os.listdir(os.path.join(tmpdir, 'examples'))


if __name__ == '__main__':
pytest.main([__file__])

0 comments on commit 74ccfc4

Please sign in to comment.