Remove make_docs.py and legacy analytics template Remove the scripts/make_docs.py wrapper and invoke sphinx-build directly from CMake, setting the homepage title natively via .. title:: in docs/source/index.rst. Remove docs/source/_templates/layout.html, which only injected obsolete Universal Analytics tracking code. Change-Id: I0f2a55b4cb7940837d152b4576c6ef7dfa2b798a
diff --git a/docs/source/CMakeLists.txt b/docs/source/CMakeLists.txt index 1f8fed8..1164484 100644 --- a/docs/source/CMakeLists.txt +++ b/docs/source/CMakeLists.txt
@@ -1,5 +1,6 @@ # HTML output directory set(SPHINX_HTML_DIR "${Ceres_BINARY_DIR}/docs/html") +set(SPHINX_DOCTREES_DIR "${Ceres_BINARY_DIR}/docs/doctrees") # Install documentation install(DIRECTORY ${SPHINX_HTML_DIR} @@ -7,15 +8,11 @@ COMPONENT Doc PATTERN "${SPHINX_HTML_DIR}/*") -# Find python -find_package(Python REQUIRED COMPONENTS Interpreter) - -# Building using 'make_docs.py' python script add_custom_target(ceres_docs ALL - $<TARGET_FILE:Python::Interpreter> - "${Ceres_SOURCE_DIR}/scripts/make_docs.py" - "${Ceres_SOURCE_DIR}" - "${Ceres_BINARY_DIR}/docs" "${Sphinx_BUILD_EXECUTABLE}" + -n -a -b html + -d "${SPHINX_DOCTREES_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${SPHINX_HTML_DIR}" USES_TERMINAL COMMENT "Building HTML documentation with Sphinx")
diff --git a/docs/source/_templates/layout.html b/docs/source/_templates/layout.html deleted file mode 100644 index 61c8eb5..0000000 --- a/docs/source/_templates/layout.html +++ /dev/null
@@ -1,13 +0,0 @@ -{% extends "!layout.html" %} - -{% block footer %} -{{ super() }} -<script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - ga('create', 'UA-49769510-1', 'ceres-solver.org'); - ga('send', 'pageview'); -</script> -{% endblock %}
diff --git a/docs/source/conf.py b/docs/source/conf.py index 470bde3..518eb6a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py
@@ -25,9 +25,6 @@ # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.ifconfig', 'sphinxcontrib.jquery'] -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - # The encoding of source files. #source_encoding = 'utf-8-sig'
diff --git a/docs/source/index.rst b/docs/source/index.rst index e6ab3a6..8aace14 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst
@@ -1,3 +1,5 @@ +.. title:: A Large Scale Non-linear Optimization Library + ============ Ceres Solver ============
diff --git a/scripts/make_docs.py b/scripts/make_docs.py deleted file mode 100644 index 9eab97e..0000000 --- a/scripts/make_docs.py +++ /dev/null
@@ -1,80 +0,0 @@ -#!/usr/bin/python3 -# encoding: utf-8 -# -# Ceres Solver - A fast non-linear least squares minimizer -# Copyright 2023 Google Inc. All rights reserved. -# http://ceres-solver.org/ -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * 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. -# * Neither the name of Google Inc. nor the names of its contributors may be -# used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR 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. -# -# Author: sameeragarwal@google.com (Sameer Agarwal) -# -# Note: You will need Sphinx and Pygments installed for this to work. - -from __future__ import print_function -import glob -import io -import os -import sys - -# Number of arguments -N = len(sys.argv) - -if N < 3: - print('make_docs.py src_root destination_root') - sys.exit(1) - -src_dir = sys.argv[1] + '/docs/source' -build_root = sys.argv[2] -cache_dir = build_root + '/doctrees' -html_dir = build_root + '/html' - -# Called from Command Line -if N == 3: - sphinx_exe = 'sphinx-build' - -# Called from CMake (using the SPHINX_EXECUTABLE found) -elif N == 4: - sphinx_exe = sys.argv[3] - -# Run Sphinx to build the documentation. -os.system('%s -n -a -d %s %s %s' %(sphinx_exe, cache_dir, src_dir, html_dir)) - -replacements = [ - # The title for the homepage is not ideal, so change it. - ('<title>Ceres Solver — Ceres Solver</title>', - '<title>Ceres Solver — A Large Scale Non-linear Optimization Library</title>') -] - -for name in glob.glob('%s/*.html' % html_dir): - print('Postprocessing: ', name) - with io.open(name, encoding="utf-8") as fptr: - out = fptr.read() - - for input_pattern, output_pattern in replacements: - out = out.replace(input_pattern, output_pattern) - - with io.open(name, 'w', encoding="utf-8") as fptr: - fptr.write(out)