Skip to content

Commit

Permalink
Replace doxygen with doxygen+sphinx as doc tool
Browse files Browse the repository at this point in the history
* Using doxygen+breathe+recommonmark+sphinx tools set, a better
  looking and usable documentation can be generated.

* Themes can be switched by replacing theme property in docs/conf.py.

* Removed obsolete doxygen files used by html format

* Add docs generation tools requirements to README. Note python3
  is the preferred and recommended version for docs generation.
  • Loading branch information
9prady9 committed Jun 17, 2019
1 parent d47cc0b commit 4b24379
Show file tree
Hide file tree
Showing 22 changed files with 697 additions and 1,632 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ endif()

#packages not available via hunter
find_package(Doxygen QUIET)
find_package(Sphinx QUIET)
find_package(FreeImage QUIET)
if(UNIX)
find_package(FontConfig REQUIRED)
endif()

option(FG_BUILD_DOCS
"Build Documentation" ${DOXYGEN_FOUND})
"Build Documentation" $<AND:${DOXYGEN_FOUND},${Sphinx_FOUND}>)
option(FG_BUILD_EXAMPLES
"Build Examples" ON)
option(FG_WITH_FREEIMAGE
Expand Down
9 changes: 9 additions & 0 deletions CMakeModules/FindSphinx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
DOC "Path to sphinx-build executable")

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(Sphinx
"Failed to find sphinx-build executable"
SPHINX_EXECUTABLE)
3 changes: 0 additions & 3 deletions CMakeModules/examples.dox.in

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ An OpenGL interop library that can be used with ArrayFire or any other applicati

### Documentation

You can find the most recent and updated documentation [here](http://arrayfire.org/forge/index.htm).
You can find the latest documentation [here](http://arrayfire.org/forge/index.htm).

### Dependencies

Expand All @@ -19,6 +19,9 @@ You can find the most recent and updated documentation [here](http://arrayfire.o
- [boost](https://www.boost.org/) - not a runtime dependency.
- [FreeImage](http://freeimage.sourceforge.net/) (optional).
- [fontconfig](http://www.freedesktop.org/wiki/Software/fontconfig/) on Linux and OSX.
- Documentation Generation (preferred & recommended version of python is 3.\*)
* [Doxygen](http://doxygen.nl/)
* [Sphinx](http://www.sphinx-doc.org/) with extensions: [Breathe](https://breathe.readthedocs.io/en/latest/), [recommonmark](https://recommonmark.readthedocs.io/en/latest/)

**Linux/Unix**: Dependencies should be available via respective package managers.
**Windows**: We recommend [vcpkg](https://github.com/Microsoft/vcpkg).
Expand Down
63 changes: 30 additions & 33 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,44 @@ set(EXAMPLES_DIR "${PROJECT_SOURCE_DIR}/examples")
configure_file(${FG_DOCS_CONFIG} ${FG_DOCS_CONFIG_OUT})
configure_file(${FG_DOCS_LAYOUT} ${FG_DOCS_LAYOUT_OUT})

###########################################################
## This generates a list of the examples cpp files and
## creates a dox file under docs/details/examples.dox
## This is used to generate documentation for examples
###########################################################
file(GLOB EXAMPLES_CPP
"${EXAMPLES_DIR}/cpu/*.cpp"
"${EXAMPLES_DIR}/cuda/*.cu"
"${EXAMPLES_DIR}/opencl/*.cpp"
"${EXAMPLES_DIR}/opencl/*.h"
)

# Sort alphabetically
# Note: example directories will be major sort order
list(SORT EXAMPLES_CPP)

# Get filenames and write to a string
foreach(SRC ${EXAMPLES_CPP})
get_filename_component(DIR_PATH ${SRC} DIRECTORY)
get_filename_component(DIR_NAME ${DIR_PATH} NAME)
get_filename_component(SRC_NAME ${SRC} NAME)
set(EXAMPLES_LIST "${EXAMPLES_LIST}\\example ${DIR_NAME}/${SRC_NAME}\n")
endforeach(SRC ${EXAMPLES_CPP})

# Write string containing file names to examples.dox
configure_file(
${PROJECT_SOURCE_DIR}/CMakeModules/examples.dox.in
${DOCS_DIR}/details/examples.dox
)
###########################################################

add_custom_target(docs
ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${FG_DOCS_CONFIG_OUT}
COMMAND cmake -E copy_directory ${ASSETS_DIR} ${CMAKE_CURRENT_BINARY_DIR}/html
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating Documentation"
VERBATIM)

set(SPHINX_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(SPHINX_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/sphinx")
set(SPHINX_INDEX_FILE ${SPHINX_BUILD_DIR}/index.html)
set(DOXY_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/xml)
set(DOXY_INDEX_FILE ${DOXY_OUT_DIR}/index.xml)

file(GLOB restFiles rst/*.rst)
file(GLOB mdFiles markdown/*.md)

# Only regenerate Sphinx when:
# - Doxygen has rerun
# - Our doc files have been updated
# - The Sphinx config has been updated
add_custom_command(OUTPUT ${SPHINX_INDEX_FILE}
COMMAND
${SPHINX_EXECUTABLE} -Dbreathe_projects.Forge=${DOXY_OUT_DIR}
${SPHINX_SOURCE_DIR} ${SPHINX_BUILD_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/index.rst
${DOXY_INDEX_FILE}
${restFiles}
${mdFiles}
MAIN_DEPENDENCY ${SPHINX_SOURCE_DIR}/conf.py
COMMENT "Generating documentation with Sphinx")

# Nice named target so we can run the job easily
add_custom_target(Sphinx ALL DEPENDS ${SPHINX_INDEX_FILE} docs)

# Install Doxygen documentation
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sphinx
DESTINATION ${FG_INSTALL_DOC_DIR}
COMPONENT documentation
PATTERN "*"
Expand Down
177 changes: 177 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Forge documentation build configuration file, created by
# sphinx-quickstart on Tue Jun 4 14:52:58 2019.
#
# 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.

# 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.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- 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.mathjax', 'breathe', 'recommonmark']

# Breathe Configuration
breathe_default_project = "Forge"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'Forge'
copyright = '2019 ArrayFire'
author = 'technical@arrayfire.com'

# 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 = '1.0'
# The full version, including alpha/beta/rc tags.
release = '1.0.4'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False


# -- 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 = 'sphinx_rtd_theme'
#html_theme_path = ['.']

# 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 = {
'style_nav_header_background':'#073763',
# Toc options
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': 4,
}
html_favicon = '../assets/arrayfire.ico'
html_logo = '../assets/arrayfire_icon.png'

# 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']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Forgedoc'


# -- 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': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# 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 = [
(master_doc, 'Forge.tex', 'Forge Documentation',
'technical@arrayfire.com', 'manual'),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'forge', 'Forge Documentation',
[author], 1)
]


# -- 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 = [
(master_doc, 'Forge', 'Forge Documentation',
author, 'Forge', 'One line description of project.',
'Miscellaneous'),
]
Empty file removed docs/details/.gitignore
Empty file.
15 changes: 7 additions & 8 deletions docs/doxygen.mk
Original file line number Diff line number Diff line change
Expand Up @@ -757,10 +757,9 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT = ${DOCS_DIR}/pages \
INPUT = ${DOCS_DIR}/markdown \
${INCLUDE_DIR}/ \
${INCLUDE_DIR}/fg/ \
${DOCS_DIR}/details
${INCLUDE_DIR}/fg/

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -898,7 +897,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.

USE_MDFILE_AS_MAINPAGE = ${DOCS_DIR}/pages/README.md
#USE_MDFILE_AS_MAINPAGE = ${DOCS_DIR}/markdown/README.md

#---------------------------------------------------------------------------
# Configuration options related to source browsing
Expand Down Expand Up @@ -1019,7 +1018,7 @@ IGNORE_PREFIX =
# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output
# The default value is: YES.

GENERATE_HTML = YES
GENERATE_HTML = NO

# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
Expand Down Expand Up @@ -1054,7 +1053,7 @@ HTML_FILE_EXTENSION = .htm
# of the possible markers and block names see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_HEADER = ${DOCS_DIR}/header.html
#HTML_HEADER = ${DOCS_DIR}/header.html

# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
# generated HTML page. If the tag is left blank doxygen will generate a standard
Expand All @@ -1064,7 +1063,7 @@ HTML_HEADER = ${DOCS_DIR}/header.html
# that doxygen normally uses.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_FOOTER = ${DOCS_DIR}/footer.html
#HTML_FOOTER = ${DOCS_DIR}/footer.html

# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
# sheet that is used by each HTML page. It can be used to fine-tune the look of
Expand Down Expand Up @@ -1810,7 +1809,7 @@ MAN_LINKS = NO
# captures the structure of the code including all documentation.
# The default value is: NO.

GENERATE_XML = NO
GENERATE_XML = YES

# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
Expand Down
21 changes: 0 additions & 21 deletions docs/footer.html

This file was deleted.

Loading

0 comments on commit 4b24379

Please sign in to comment.