Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and deploy TriBITS documentation with Sphinx (#386) #387

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
188b399
#386: - added sphinx setup
marcinwrobel1986 Jun 30, 2021
70b8bc5
#386: - added requirements.txt
marcinwrobel1986 Jun 30, 2021
83f4338
#386: - trying to avoid duplicates
marcinwrobel1986 Jun 30, 2021
1c72600
#386: - hopefully fixed symlinks
marcinwrobel1986 Jun 30, 2021
0d20189
#386: - updated index.rst
marcinwrobel1986 Jul 1, 2021
229eb1d
#386: - set up github action
marcinwrobel1986 Jul 1, 2021
be68455
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
690e7a2
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
616610e
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
1f742a5
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
9b9cdb2
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
93a1376
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
1efe2e2
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
35aa571
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
3da1326
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
768b483
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
0997da7
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
e97da1b
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
9935210
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
966c259
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
37dc47f
#386: - setting up github action
marcinwrobel1986 Jul 1, 2021
b2ff84e
#386: - added deployment
marcinwrobel1986 Jul 1, 2021
26324dc
#386: - trying deployment
marcinwrobel1986 Jul 1, 2021
96c461e
#386: - added current year
marcinwrobel1986 Jul 1, 2021
f9f9676
#386: - added nojekyll file
marcinwrobel1986 Jul 1, 2021
3568275
#386: - turn on numbering
marcinwrobel1986 Jul 1, 2021
1205783
#386: - improve numbering
marcinwrobel1986 Jul 2, 2021
e3d6142
#386: - removed not used element
marcinwrobel1986 Jul 2, 2021
49dc3e2
#386: - added author and date to main doc page
marcinwrobel1986 Jul 2, 2021
782b14f
#386: - simplified file names
marcinwrobel1986 Jul 2, 2021
72eb4a8
#386: - check the toctree depth
marcinwrobel1986 Jul 5, 2021
aa33c22
#386: - check hiden option with indices
marcinwrobel1986 Jul 5, 2021
d8f7fee
#386: - Simplified landing page
marcinwrobel1986 Jul 5, 2021
60227a5
#386: - added abstract
marcinwrobel1986 Jul 5, 2021
51422c5
#386: - checking ref links
marcinwrobel1986 Jul 5, 2021
9f4d9a1
#386: - added ref links to documentation
marcinwrobel1986 Jul 5, 2021
22befca
#386: - changed trigerred branch to master
marcinwrobel1986 Jul 9, 2021
ca3c6a1
#386: - added theme config
marcinwrobel1986 Jul 9, 2021
fd599dc
#386: - deploy docs
marcinwrobel1986 Jul 9, 2021
cf2a284
#386: - trying RTD configuration
marcinwrobel1986 Jul 13, 2021
6353205
#386: - changed name for check_file
marcinwrobel1986 Jul 13, 2021
5efa447
#386: - fixed type
marcinwrobel1986 Jul 13, 2021
7cd93c5
#386: - fixed import
marcinwrobel1986 Jul 13, 2021
26ac253
#386: - fixed import
marcinwrobel1986 Jul 13, 2021
b902559
#386: - try to use both python interpreters
marcinwrobel1986 Jul 13, 2021
de4e287
#386: - removed RTD attempt
marcinwrobel1986 Jul 13, 2021
c5aa145
Separation into 3 Sphinx docs (#386)
marcinwrobel1986 Jul 14, 2021
efdd598
#386: - added Sphinx generation
marcinwrobel1986 Jul 14, 2021
0369107
#386: - provided landing page for docs
marcinwrobel1986 Jul 15, 2021
71cdbf3
#386: - fixed typo
marcinwrobel1986 Jul 15, 2021
3b02608
#386: - fixed typo
marcinwrobel1986 Jul 15, 2021
7cabc31
Run job only when push on master branch (#386)
marcinwrobel1986 Jul 15, 2021
916d534
Fix typo in name 'maintainers_guide' (#386)
bartlettroscoe Jul 16, 2021
77fa87b
Removed python3 deps (#386)
marcinwrobel1986 Jul 19, 2021
7b467d5
Check deployment job (#386)
marcinwrobel1986 Jul 19, 2021
ddf4e65
Changed page titles (#386)
marcinwrobel1986 Jul 20, 2021
a66427a
Remove modification of .rst files (#386)
marcinwrobel1986 Jul 20, 2021
8d28c1b
#386: - only deploy when push to master
marcinwrobel1986 Jul 20, 2021
769ebca
Add missing 'Generic' to title of generic build reference (#386)
bartlettroscoe Jul 22, 2021
f746fa4
Fix create-build-ref.sh --skip-final-generation to generate final *.r…
bartlettroscoe Jul 22, 2021
e5dd4ab
Update to call build_docs.sh --skip-final-generation (#363)
bartlettroscoe Jul 22, 2021
07d244b
Remove need to cd into dir to call build_docs.sh (#363)
bartlettroscoe Jul 22, 2021
f6a9311
Add test build_sphinx_docs (#368)
bartlettroscoe Jul 22, 2021
8567fef
Add driver script to rebuild sphinx documentation (#386)
bartlettroscoe Jul 23, 2021
41551fd
Uses build_sphinx_docs.sh in test and add rebuild (#386)
bartlettroscoe Jul 23, 2021
bafff87
Reformat to fit in 90 char wide (#386)
bartlettroscoe Jul 23, 2021
fbb2ac9
Factor out change_paths_and_get_includes() and is_rst_file() to be un…
bartlettroscoe Jul 23, 2021
8e071ce
Add failing unit test for change_paths_and_get_includes() (#386)
bartlettroscoe Jul 23, 2021
1d66677
Fix bug to maintain indent for transformed include directives (#386)
bartlettroscoe Jul 23, 2021
1708a5b
Add ctest driver for sphinx_rst_generator_UnitTests.py (#386)
bartlettroscoe Jul 23, 2021
65396aa
Remove unneeded package includes, including deprecated packages (#386)
bartlettroscoe Jul 24, 2021
3dcb5b6
Add arg change_paths_and_get_includes( ... copy_file: bool = True ) (…
bartlettroscoe Jul 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy docs

on:
push:
branches: [ master ]

jobs:
build-and-deploy-docs:

runs-on: ubuntu-latest
env:
working-directory: ./tribits/doc/sphinx

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
architecture: 'x64'
- name: Display Python version
run: |
python -c "import sys; print(sys.version)"
python3 -c "import sys; print(sys.version)"
- name: Install Python dependencies
run: |
pip3 install sphinx sphinx-rtd-theme
- name: Build documentation
working-directory: ${{env.working-directory}}
run: python3 sphinx_rst_generator.py
- name: Generate nojekyll file
working-directory: ${{env.working-directory}}/combined_docs
run: touch .nojekyll
- name: Deploy docs
uses: JamesIves/[email protected]
with:
branch: deploy-doc-site
folder: ${{env.working-directory}}/combined_docs
clean: true
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ build/

# Ignore the standard local gitdist override file
/.gitdist

# Python environment
venv

# Pycharm settings
.idea
63 changes: 63 additions & 0 deletions test/doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ advanced_set( ${PROJECT_NAME}_ENABLE_DOC_GENERATION_TESTS OFF
"Enable testing for the build of the documentation. Requries docutils and will blow away and rebuild the existing documentation in the source tree since the documentation builds in place." )


tribits_add_advanced_test( sphinx_rst_generator_UnitTests
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
EXCLUDE_IF_NOT_TRUE HAS_PYTHON3
TEST_0 CMND ${PYTHON_EXECUTABLE}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/sphinx_rst_generator_UnitTests.py -v
PASS_REGULAR_EXPRESSION "OK"
ALWAYS_FAIL_ON_NONZERO_RETURN
)


tribits_add_advanced_test( build_docs
EXCLUDE_IF_NOT_TRUE ${PROJECT_NAME}_ENABLE_DOC_GENERATION_TESTS
GIT_EXECUTABLE
Expand All @@ -25,4 +36,56 @@ tribits_add_advanced_test( build_docs
ARGS ${PROJECT_SOURCE_DIR}/tribits/doc/guides/maintainers_guide/TribitsMaintainersGuide.html
PASS_REGULAR_EXPRESSION guides/maintainers_guide/TribitsMaintainersGuide.html
ALWAYS_FAIL_ON_NONZERO_RETURN
ADDED_TEST_NAME_OUT build_docs_test_name
)


tribits_add_advanced_test( build_sphinx_docs
EXCLUDE_IF_NOT_TRUE ${PROJECT_NAME}_ENABLE_DOC_GENERATION_TESTS
GIT_EXECUTABLE
OVERALL_NUM_MPI_PROCS 1
TEST_0 MESSAGE "Clean out any prior build of the docs"
CMND ${GIT_EXECUTABLE} ARGS clean -xdf
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tribits/doc
SKIP_CLEAN_WORKING_DIRECTORY # Don't delete our source tree!
TEST_1 MESSAGE "Build the sphinx documentation"
CMND bash ARGS ${PROJECT_SOURCE_DIR}/tribits/doc/sphinx/build_sphinx_docs.sh
TEST_2 CMND ls
ARGS ${PROJECT_SOURCE_DIR}/tribits/doc/sphinx/combined_docs/index.html
PASS_REGULAR_EXPRESSION sphinx/combined_docs/index.html
ALWAYS_FAIL_ON_NONZERO_RETURN
TEST_3 CMND ls
ARGS ${PROJECT_SOURCE_DIR}/tribits/doc/sphinx/combined_docs/build_ref/index.html
PASS_REGULAR_EXPRESSION sphinx/combined_docs/build_ref/index.html
ALWAYS_FAIL_ON_NONZERO_RETURN
TEST_4 CMND ls
ARGS ${PROJECT_SOURCE_DIR}/tribits/doc/sphinx/combined_docs/users_guide/index.html
PASS_REGULAR_EXPRESSION sphinx/combined_docs/users_guide/index.html
ALWAYS_FAIL_ON_NONZERO_RETURN
TEST_5 CMND ls
ARGS ${PROJECT_SOURCE_DIR}/tribits/doc/sphinx/combined_docs/maintainers_guide/index.html
PASS_REGULAR_EXPRESSION sphinx/combined_docs/maintainers_guide/index.html
ALWAYS_FAIL_ON_NONZERO_RETURN
TEST_6 MESSAGE "Rebuld the sphinx documentation to show you can without error"
CMND bash ARGS ${PROJECT_SOURCE_DIR}/tribits/doc/sphinx/build_sphinx_docs.sh
ADDED_TEST_NAME_OUT build_sphinx_docs_test_name
)

if (build_docs_test_name AND build_sphinx_docs_test_name)
set_tests_properties( ${build_sphinx_docs_test_name}
PROPERTIES DEPENDS ${build_docs_test_name})
# Above sets a dependency of testing the build the sphinx documentation to
# come after testing the build of the regular docutils documentation. The
# latter does not really depend on the fommer but both of these clean out
# the uncommitted files under tribits/doc/ and we don't want these two tests
# stomping on each other. We also don't want to label these two tests with
# RUN_SERIAL because they take a long time to run and we don't want to stop
# other TriBITS tests from running at the same time as these two.
endif()


if (PYTHON_VERSION_MAJOR GREATER_EQUAL 3)
set(HAS_PYTHON3 TRUE)
else()
set(HAS_PYTHON3 FALSE)
endif()
48 changes: 48 additions & 0 deletions test/doc/FindTestDocDir.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# @HEADER
# ************************************************************************
#
# TriBITS: Tribal Build, Integrate, and Test System
# Copyright 2013 Sandia Corporation
#
# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
# the U.S. Government retains certain rights in this software.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Corporation nor the names of the
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ************************************************************************
# @HEADER

import os
import sys

testDocDir = os.path.dirname(os.path.abspath(__file__))
tribitsDir = os.path.abspath(os.path.join(testDocDir,"../../tribits"))
docSphinxDir = os.path.join(tribitsDir,"doc","sphinx")
pythonUtilsDir = os.path.join(tribitsDir,"python_utils")

sys.path = [docSphinxDir, pythonUtilsDir] + sys.path
23 changes: 23 additions & 0 deletions test/doc/data/TribitsGuidesBody.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
This is a stand-in for the TribitsGuidesBody.rst file with indented includes.

Something something:

.. include:: ../../examples/TribitsExampleProject/ProjectName.cmake
:literal:

4) Add custom CTest -S driver scripts.

For driving different builds and tests, one needs to set up one or more
CTest -S driver scripts. There are various ways to do this but a simple
approach that avoids duplication is to first create a file like
``TribitsExampleProject/cmake/ctest/TribitsExProjCTestDriver.cmake``:

.. include:: ../../examples/TribitsExampleProject/cmake/ctest/TribitsExProjCTestDriver.cmake
:literal:

and then create a set of CTest -S driver scripts that uses that file. One
example is the file
``TribitsExampleProject/cmake/ctest/general_gcc/ctest_serial_debug.cmake``:

.. include:: ../../examples/TribitsExampleProject/cmake/ctest/general_gcc/ctest_serial_debug.cmake
:literal:
104 changes: 104 additions & 0 deletions test/doc/sphinx_rst_generator_UnitTests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @HEADER
# ************************************************************************
#
# TriBITS: Tribal Build, Integrate, and Test System
# Copyright 2013 Sandia Corporation
#
# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
# the U.S. Government retains certain rights in this software.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Corporation nor the names of the
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ************************************************************************
# @HEADER

#################################################
# Unit testing code for sphinx_rst_generator.py #
#################################################

import unittest

from FindTestDocDir import *
import sphinx_rst_generator as SRG


#
# Unit tests for sphinx_rst_generator.change_paths_and_get_includes()
#


tribitsGuideBodyCopied_expected = \
r"""This is a stand-in for the TribitsGuidesBody.rst file with indented includes.

Something something:

.. include:: ../copied_files/ProjectName.cmake
:literal:

4) Add custom CTest -S driver scripts.

For driving different builds and tests, one needs to set up one or more
CTest -S driver scripts. There are various ways to do this but a simple
approach that avoids duplication is to first create a file like
``TribitsExampleProject/cmake/ctest/TribitsExProjCTestDriver.cmake``:

.. include:: ../copied_files/TribitsExProjCTestDriver.cmake
:literal:

and then create a set of CTest -S driver scripts that uses that file. One
example is the file
``TribitsExampleProject/cmake/ctest/general_gcc/ctest_serial_debug.cmake``:

.. include:: ../copied_files/ctest_serial_debug.cmake
:literal:
"""


class test_change_paths_and_get_includes(unittest.TestCase):


def test_1(self):
src_file_path = os.path.join(testDocDir,'data')
source_file = os.path.join(src_file_path,'TribitsGuidesBody.rst')
start_path = os.path.join(tribitsDir,'doc','sphinx','users_guide')
rst_dir = os.path.join(tribitsDir,'doc','sphinx','copied_files')
(abs_path_str, include_file_list) = SRG.change_paths_and_get_includes(
source_file=source_file, src_file_path=src_file_path,
start_path=start_path, rst_dir=rst_dir, copy_file=True)
#print("abs_path_str = "+str(abs_path_str))
#print("include_file_list = "+str(include_file_list))
self.maxDiff = None
self.assertEqual(abs_path_str, tribitsGuideBodyCopied_expected)
include_file_list_expected = set()
self.assertEqual(include_file_list, include_file_list_expected)


if __name__ == '__main__':
unittest.main()
18 changes: 10 additions & 8 deletions tribits/doc/build_ref/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ EXTRA_FILES = \
# NOTE: We *don't* want to rebuild the file if only the version has changed we
# don't add a dependency on TribitsGitVersion.txt!

all: $(BASE_NAME).rst $(BASE_NAME).html $(BASE_NAME).pdf

$(BASE_NAME).pdf: $(BASE_NAME).html

$(BASE_NAME).html: $(BASE_NAME).rst

$(BASE_NAME).rst: $(EXTRA_FILES)
CREATE_PROJECT_BUILD_REF_CMND = \
./create-project-build-ref.py \
--project-name="<Project>" \
--project-template-file=TribitsBuildReferenceTemplate.rst \
--file-base=TribitsBuildReference \
--file-base=TribitsBuildReference

all: $(EXTRA_FILES)
$(CREATE_PROJECT_BUILD_REF_CMND) \
$(EXTRA_ARGS)

$(BASE_NAME).rst: $(EXTRA_FILES)
$(CREATE_PROJECT_BUILD_REF_CMND) \
--generate-html= --generate-latex= --generate-pdf= \
$(EXTRA_ARGS)

clean:
Expand Down
3 changes: 2 additions & 1 deletion tribits/doc/build_ref/create-build-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if [[ "${skip_final_generation}" == "0" ]] ; then
make
else
echo
echo "Skipping geneation of HTML and PDF files on request!"
echo "Only generating the file TribitsBuildReference.rst on request!"
echo
make TribitsBuildReference.rst
fi
20 changes: 20 additions & 0 deletions tribits/doc/sphinx/build_ref/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Empty file.
Loading