From ac8d347e9e7a3392f9ae3a81373977ad63942056 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Tue, 5 Jul 2016 12:07:31 +0200 Subject: [PATCH] we have html output and autodoc functionality --- CMakeLists.txt | 4 + cmake/FindSphinx.cmake | 145 +++++++++++++++ docs/CMakeLists.txt | 27 +++ docs/sphinx/run_sphinx_build.sh.in | 7 + docs/sphinx/source/conf.py.in | 275 +++++++++++++++++++++++++++++ docs/sphinx/source/index.rst | 19 ++ docs/sphinx/source/mwbase.rst | 33 ++++ docs/sphinx/source/openmw.rst | 16 ++ 8 files changed, 526 insertions(+) create mode 100644 cmake/FindSphinx.cmake create mode 100644 docs/CMakeLists.txt create mode 100644 docs/sphinx/run_sphinx_build.sh.in create mode 100644 docs/sphinx/source/conf.py.in create mode 100644 docs/sphinx/source/index.rst create mode 100644 docs/sphinx/source/mwbase.rst create mode 100644 docs/sphinx/source/openmw.rst diff --git a/CMakeLists.txt b/CMakeLists.txt index 14a1c15c8..e5ecd1f62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -829,3 +829,7 @@ if (DOXYGEN_FOUND) WORKING_DIRECTORY ${OpenMW_BINARY_DIR} COMMENT "Generating documentation for the github-pages at ${DOXYGEN_PAGES_OUTPUT_DIR}" VERBATIM) endif () + + +OPTION(WANT_DOCS "Build documentation." OFF ) +ADD_SUBDIRECTORY(docs) diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake new file mode 100644 index 000000000..4607f7806 --- /dev/null +++ b/cmake/FindSphinx.cmake @@ -0,0 +1,145 @@ +# - This module looks for Sphinx +# Find the Sphinx documentation generator +# +# This modules defines +# SPHINX_EXECUTABLE +# SPHINX_FOUND + +find_program(SPHINX_EXECUTABLE + NAMES sphinx-build + PATHS + /usr/bin + /usr/local/bin + /opt/local/bin + DOC "Sphinx documentation generator" +) + +if( NOT SPHINX_EXECUTABLE ) + set(_Python_VERSIONS + 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5 + ) + + foreach( _version ${_Python_VERSIONS} ) + set( _sphinx_NAMES sphinx-build-${_version} ) + + find_program( SPHINX_EXECUTABLE + NAMES ${_sphinx_NAMES} + PATHS + /usr/bin + /usr/local/bin + /opt/loca/bin + DOC "Sphinx documentation generator" + ) + endforeach() +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Sphinx DEFAULT_MSG + SPHINX_EXECUTABLE +) + + +option( SPHINX_HTML_OUTPUT "Build a single HTML with the whole content." ON ) +option( SPHINX_DIRHTML_OUTPUT "Build HTML pages, but with a single directory per document." OFF ) +option( SPHINX_HTMLHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in htmlhelp." OFF ) +option( SPHINX_QTHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in qthelp." OFF ) +option( SPHINX_DEVHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in devhelp." OFF ) +option( SPHINX_EPUB_OUTPUT "Build HTML pages with additional information for building a documentation collection in epub." OFF ) +option( SPHINX_LATEX_OUTPUT "Build LaTeX sources that can be compiled to a PDF document using pdflatex." OFF ) +option( SPHINX_MAN_OUTPUT "Build manual pages in groff format for UNIX systems." OFF ) +option( SPHINX_TEXT_OUTPUT "Build plain text files." OFF ) + + +mark_as_advanced( + SPHINX_EXECUTABLE + SPHINX_HTML_OUTPUT + SPHINX_DIRHTML_OUTPUT + SPHINX_HTMLHELP_OUTPUT + SPHINX_QTHELP_OUTPUT + SPHINX_DEVHELP_OUTPUT + SPHINX_EPUB_OUTPUT + SPHINX_LATEX_OUTPUT + SPHINX_MAN_OUTPUT + SPHINX_TEXT_OUTPUT +) + +function( Sphinx_add_target target_name builder conf source destination ) + add_custom_target( ${target_name} ALL + COMMAND ${SPHINX_EXECUTABLE} -b ${builder} + -c ${conf} + ${source} + ${destination} + COMMENT "Generating sphinx documentation: ${builder}" + ) + + set_property( + DIRECTORY APPEND PROPERTY + ADDITIONAL_MAKE_CLEAN_FILES + ${destination} + ) +endfunction() + +# Target dependencies can be optionally listed at the end. +function( Sphinx_add_targets target_base_name conf source base_destination ) + + set( _dependencies ) + + foreach( arg IN LISTS ARGN ) + set( _dependencies ${_dependencies} ${arg} ) + endforeach() + + if( ${SPHINX_HTML_OUTPUT} ) + Sphinx_add_target( ${target_base_name}_html html ${conf} ${source} ${base_destination}/html ) + + add_dependencies( ${target_base_name}_html ${_dependencies} ) + endif() + + if( ${SPHINX_DIRHTML_OUTPUT} ) + Sphinx_add_target( ${target_base_name}_dirhtml dirhtml ${conf} ${source} ${base_destination}/dirhtml ) + + add_dependencies( ${target_base_name}_dirhtml ${_dependencies} ) + endif() + + if( ${SPHINX_QTHELP_OUTPUT} ) + Sphinx_add_target( ${target_base_name}_qthelp qthelp ${conf} ${source} ${base_destination}/qthelp ) + + add_dependencies( ${target_base_name}_qthelp ${_dependencies} ) + endif() + + if( ${SPHINX_DEVHELP_OUTPUT} ) + Sphinx_add_target( ${target_base_name}_devhelp devhelp ${conf} ${source} ${base_destination}/devhelp ) + + add_dependencies( ${target_base_name}_devhelp ${_dependencies} ) + endif() + + if( ${SPHINX_EPUB_OUTPUT} ) + Sphinx_add_target( ${target_base_name}_epub epub ${conf} ${source} ${base_destination}/epub ) + + add_dependencies( ${target_base_name}_epub ${_dependencies} ) + endif() + + if( ${SPHINX_LATEX_OUTPUT} ) + Sphinx_add_target( ${target_base_name}_latex latex ${conf} ${source} ${base_destination}/latex ) + + add_dependencies( ${target_base_name}_latex ${_dependencies} ) + endif() + + if( ${SPHINX_MAN_OUTPUT} ) + Sphinx_add_target( ${target_base_name}_man man ${conf} ${source} ${base_destination}/man ) + + add_dependencies( ${target_base_name}_man ${_dependencies} ) + endif() + + if( ${SPHINX_TEXT_OUTPUT} ) + Sphinx_add_target( ${target_base_name}_text text ${conf} ${source} ${base_destination}/text ) + + add_dependencies( ${target_base_name}_text ${_dependencies} ) + endif() + + if( ${BUILD_TESTING} ) + sphinx_add_target( ${target_base_name}_linkcheck linkcheck ${conf} ${source} ${base_destination}/linkcheck ) + + add_dependencies( ${target_base_name}_linkcheck ${_dependencies} ) + endif() +endfunction() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 000000000..c63d6dc18 --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1,27 @@ +IF( WANT_DOCS ) + # Builds the documentation. + FIND_PACKAGE( Sphinx REQUIRED ) + FIND_PACKAGE( Doxygen REQUIRED ) + + SET( SPHINX_SOURCE_DIR ${CMAKE_SOURCE_DIR}/docs/sphinx ) + SET( DOCUMENTATION_DIR ${OpenMW_BINARY_DIR}/docs ) + + FILE(MAKE_DIRECTORY ${DOCUMENTATION_DIR}/_static) + FILE(MAKE_DIRECTORY ${DOCUMENTATION_DIR}/_templates) + + CONFIGURE_FILE( + ${SPHINX_SOURCE_DIR}/source/conf.py.in + ${DOCUMENTATION_DIR}/conf.py + @ONLY) + + CONFIGURE_FILE( + ${SPHINX_SOURCE_DIR}/run_sphinx_build.sh.in + ${DOCUMENTATION_DIR}/run_sphinx_build.sh + @ONLY) + + IF(UNIX) + EXECUTE_PROCESS(COMMAND chmod +x ${DOCUMENTATION_DIR}/run_sphinx_build.sh OUTPUT_QUIET) + EXECUTE_PROCESS(COMMAND ${DOCUMENTATION_DIR}/run_sphinx_build.sh OUTPUT_QUIET) + ENDIF(UNIX) + +ENDIF() diff --git a/docs/sphinx/run_sphinx_build.sh.in b/docs/sphinx/run_sphinx_build.sh.in new file mode 100644 index 000000000..ddd4dc2bb --- /dev/null +++ b/docs/sphinx/run_sphinx_build.sh.in @@ -0,0 +1,7 @@ +#!/bin/bash +echo "Creating Sphinx documentation in: @SPHINX_DESTINATION@" + +LD_LIBRARY_PATH="@CMAKE_INSTALL_PREFIX@/lib:$LD_LIBRARY_PATH" + +@SPHINX_EXECUTABLE@ -b html -c @CMAKE_CURRENT_BINARY_DIR@/ @SPHINX_SOURCE_DIR@/source @DOCUMENTATION_DIR@/html +@SPHINX_EXECUTABLE@ -b man -c @CMAKE_CURRENT_BINARY_DIR@/ @SPHINX_SOURCE_DIR@/source @DOCUMENTATION_DIR@/man \ No newline at end of file diff --git a/docs/sphinx/source/conf.py.in b/docs/sphinx/source/conf.py.in new file mode 100644 index 000000000..218ef8b6d --- /dev/null +++ b/docs/sphinx/source/conf.py.in @@ -0,0 +1,275 @@ +# -*- coding: utf-8 -*- +# +# OpenMW documentation build configuration file, created by +# sphinx-quickstart on Wed May 14 15:16:35 2014. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('@CMAKE_SOURCE_DIR@')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.viewcode', + 'breathe', +] + +# Where breathe can find the source files +breathe_projects_source = { + "openmw": ("@CMAKE_SOURCE_DIR@/apps/openmw", ["engine.hpp", + "mwbase/dialoguemanager.hpp", "mwbase/environment.hpp", + "mwbase/inputmanager.hpp", "mwbase/journal.hpp", "mwbase/mechanicsmanager.hpp", + "mwbase/scriptmanager.hpp", "mwbase/soundmanager.hpp", "mwbase/statemanager.hpp", + "mwbase/windowmanager.hpp", "mwbase/world.hpp"]) + } + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'OpenMW' +copyright = u'2016, OpenMW Team' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '@OPENMW_VERSION@' +# The full version, including alpha/beta/rc tags. +release = '@OPENMW_VERSION@' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +primary_domain = 'c' + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'OpenMWdoc' + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', 'OpenMW.tex', u'OpenMW Documentation', + u'Bret Curtis', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'openmw', u'OpenMW Documentation', + [u'Bret Curtis'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'OpenMW', u'OpenMW Documentation', + u'Bret Curtis', 'OpenMW', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False diff --git a/docs/sphinx/source/index.rst b/docs/sphinx/source/index.rst new file mode 100644 index 000000000..64c3c9796 --- /dev/null +++ b/docs/sphinx/source/index.rst @@ -0,0 +1,19 @@ + +Welcome to OpenMW's documentation! +===================================== + +Components +---------- + +.. toctree:: + :maxdepth: 2 + + openmw + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`search` + diff --git a/docs/sphinx/source/mwbase.rst b/docs/sphinx/source/mwbase.rst new file mode 100644 index 000000000..4044fbc97 --- /dev/null +++ b/docs/sphinx/source/mwbase.rst @@ -0,0 +1,33 @@ +openmw/mwbase +============= + +.. autodoxygenfile:: mwbase/dialoguemanager.hpp + :project: openmw + +.. autodoxygenfile:: mwbase/environment.hpp + :project: openmw + +.. autodoxygenfile:: mwbase/inputmanager.hpp + :project: openmw + +.. autodoxygenfile:: mwbase/journal.hpp + :project: openmw + +.. autodoxygenfile:: mwbase/mechanicsmanager.hpp + :project: openmw + +.. autodoxygenfile:: mwbase/scriptmanager.hpp + :project: openmw + +.. autodoxygenfile:: mwbase/soundmanager.hpp + :project: openmw + +.. autodoxygenfile:: mwbase/statemanager.hpp + :project: openmw + +.. autodoxygenfile:: mwbase/windowmanager.hpp + :project: openmw + +.. autodoxygenfile:: mwbase/world.hpp + :project: openmw + diff --git a/docs/sphinx/source/openmw.rst b/docs/sphinx/source/openmw.rst new file mode 100644 index 000000000..2da7caa5f --- /dev/null +++ b/docs/sphinx/source/openmw.rst @@ -0,0 +1,16 @@ +openmw +====== + +.. toctree:: + :maxdepth: 2 + + mwbase + +.. autodoxygenfile:: engine.hpp + :project: openmw + +Indices and tables +================== + +* :ref:`genindex` + * :ref:`search` \ No newline at end of file