Skip to content

Commit

Permalink
Automatic C++ documentation generation (#8)
Browse files Browse the repository at this point in the history
* updated requirements.txt for building docs

* removed files from demo into main doc directory

* added RTD config file

* Update .readthedocs.yaml

* Updated python version to 3.8

* added required changes to build doxygen output using doxygen

* removed all requirements for docs

* removed command from doxygen call

* changed directory of command for doxygen

* reverted last changes and set output to build

* set the doxygen output dir to the current working directory

* added descriptors to the classes and updated README

* removed docs build pipeline from CMake

* removed files for demo

* set HIDE_UNDOC_MEMBERS to False

* removed README.md from tests

* updated some docstrings and converted demo to md file

* added missing demo folder

* replaced text tables with md tables

* removed addition of demo\ from this PR

* added undoc classes and included source files for doxygen

* removed modules by removing the 'defgroup' parameter from docstrings

* Update README.md

* re-added the images directory containing the teaser

* Updated link to new RTD site

* updates doxygent to include teaser img on index page + minor adjustment

* moved mainpage docstring to its own file

* Update src/Core/GUI/VRInterface.hpp

Co-authored-by: Christian Richardt <[email protected]>

* Update src/Core/CameraSetup/CameraSetupVisualization.hpp

Co-authored-by: Christian Richardt <[email protected]>

* Update docs/README.md

Co-authored-by: Christian Richardt <[email protected]>

* Update src/Core/Geometry/PointCloud.hpp

Co-authored-by: Christian Richardt <[email protected]>

* Update src/Core/Geometry/Sphere.hpp

Co-authored-by: Christian Richardt <[email protected]>

* updated placement of docstrings

* Update src/Core/Geometry/Circle.hpp

Co-authored-by: Christian Richardt <[email protected]>

* Update src/Core/Geometry/Circle.hpp

Co-authored-by: Christian Richardt <[email protected]>

* Update src/Core/Geometry/Cylinder.hpp

Co-authored-by: Christian Richardt <[email protected]>

* moved mainpage to src and fixed viewerapp docstring

* Update src/Core/Application.hpp

Co-authored-by: Christian Richardt <[email protected]>

* Update src/Core/CameraSetup/CameraSetupVisualization.hpp

Co-authored-by: Christian Richardt <[email protected]>

* Update src/Core/GL/GLRenderable.hpp

Co-authored-by: Christian Richardt <[email protected]>

* Update src/Core/GL/GLRenderable.hpp

Co-authored-by: Christian Richardt <[email protected]>

* removed confusing documentation

* Update src/Core/GL/GLApplication.hpp

Co-authored-by: Christian Richardt <[email protected]>

* Apply suggestions from code review

Co-authored-by: Christian Richardt <[email protected]>

* updated docs in geometry

* re-added deleted images

* fixing todos on PR #8

* adding missing documentation

* Clean up pass

* Tweak location of docs badge

* Undo previous commit

* made doxygen show private class members

* fixed todos for PR #8

* re-added empty index.rst file

* Clean-up pass

* Update README.md

Co-authored-by: rjl67 <[email protected]>
Co-authored-by: Christian Richardt <[email protected]>
  • Loading branch information
3 people authored Jul 8, 2021
1 parent faba49c commit 0e4c026
Show file tree
Hide file tree
Showing 34 changed files with 283 additions and 418 deletions.
20 changes: 20 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.8
install:
- requirements: docs/requirements.txt
11 changes: 0 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ option(USE_CERES "Use Ceres in certain apps." OFF)
option(USE_CUDA_IN_OPENCV "Use CUDA in OpenCV." OFF)

## Additional things that are not built by default.
option(WITH_DOCS "Build documentation files." OFF)
option(WITH_OPENVR "Build with OpenVR." ${OPENVR_FOUND})
option(WITH_TEST "Build tests." OFF)
option(WITH_TOOLS "Build with tools." OFF)
Expand Down Expand Up @@ -153,16 +152,6 @@ add_subdirectory(src/Core)
add_subdirectory(src/Utils)
add_subdirectory(src/PreprocessingApp)


#############################
# DOCUMENTATION
#############################

if(WITH_DOCS)
add_subdirectory(docs)
endif()


#############################
# EXECUTABLES
#############################
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# OmniPhotos: Casual 360° VR Photography
### [Project Page](https://richardt.name/publications/omniphotos/) | [Video](https://vimeo.com/456866335) | [Paper](https://richardt.name/publications/omniphotos/OmniPhotos-BertelEtAl-SIGAsia2020-paper.pdf) | [Demo](#demo) | [Data](https://doi.org/10.15125/BATH-00948)

[![Documentation Status](https://readthedocs.org/projects/omniphotos/badge/?version=latest)](https://omniphotos.readthedocs.io/en/latest/?badge=latest)


This repository contains the source code for creating and viewing OmniPhotos – a new approach for
casual 360° VR photography using a consumer 360° video camera.
Expand Down
37 changes: 0 additions & 37 deletions docs/CMakeLists.txt

This file was deleted.

23 changes: 11 additions & 12 deletions docs/Doxyfile.in → docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = "@DOXYGEN_OUTPUT_DIR@"
OUTPUT_DIRECTORY =

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -195,7 +195,7 @@ SHORT_NAMES = NO
# description.)
# The default value is: NO.

JAVADOC_AUTOBRIEF = NO
JAVADOC_AUTOBRIEF = YES

# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
# such as
Expand All @@ -205,7 +205,7 @@ JAVADOC_AUTOBRIEF = NO
# interpreted by doxygen.
# The default value is: NO.

JAVADOC_BANNER = NO
JAVADOC_BANNER = YES

# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
# line (until the first dot) of a Qt-style comment as the brief description. If
Expand All @@ -225,7 +225,7 @@ QT_AUTOBRIEF = NO
# not recognized any more.
# The default value is: NO.

MULTILINE_CPP_IS_BRIEF = NO
MULTILINE_CPP_IS_BRIEF = YES

# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
# documentation from any documented member that it re-implements.
Expand Down Expand Up @@ -473,7 +473,7 @@ EXTRACT_ALL = NO
# be included in the documentation.
# The default value is: NO.

EXTRACT_PRIVATE = NO
EXTRACT_PRIVATE = YES

# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
# methods of a class will be included in the documentation.
Expand Down Expand Up @@ -532,7 +532,7 @@ HIDE_UNDOC_MEMBERS = NO
# has no effect if EXTRACT_ALL is enabled.
# The default value is: NO.

HIDE_UNDOC_CLASSES = YES
HIDE_UNDOC_CLASSES = NO

# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
# declarations. If set to NO, these declarations will be included in the
Expand Down Expand Up @@ -829,7 +829,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = "@DOXYGEN_INPUT_DIR@"
INPUT = ../src

# 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 @@ -917,8 +917,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE = "@DOXYGEN_INPUT_DIR@/3rdParty" \
"@DOXYGEN_INPUT_DIR@/Tools"
EXCLUDE = "../src/3rdParty"

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
Expand Down Expand Up @@ -971,7 +970,7 @@ EXAMPLE_RECURSIVE = NO
# that contain images that are to be included in the documentation (see the
# \image command).

IMAGE_PATH =
IMAGE_PATH = images

# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
Expand Down Expand Up @@ -1040,7 +1039,7 @@ USE_MDFILE_AS_MAINPAGE =
# also VERBATIM_HEADERS is set to NO.
# The default value is: NO.

SOURCE_BROWSER = NO
SOURCE_BROWSER = YES

# Setting the INLINE_SOURCES tag to YES will include the body of functions,
# classes and enums directly into the documentation.
Expand Down Expand Up @@ -2040,7 +2039,7 @@ MAN_LINKS = NO
# captures the structure of the code including all documentation.
# The default value is: NO.

GENERATE_XML = YES
GENERATE_XML = NO

# 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
115 changes: 81 additions & 34 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,97 @@
# Documentation
# Building Documentation

To build the documentation, you'll first of all need to have installed doxygen and make it available on your path.
To check this, run this command and make sure it does not return an error:
To build the documentation, you will need to have [installed doxygen](https://www.doxygen.nl/download.html) (making it available on your path).
[The installation instructions](https://www.doxygen.nl/manual/install.html) could be helpful as well.
To check that doxygen is on your path, run this command and make sure it does not return an error:

doxygen --version

Secondly, you'll need to have installed the sphinx packages in the `requirements.txt` file in this directory.
To do this, generate and activate a Python environment and install the requirements:
Then run the command

doxygen

python -m venv sphinxenv
sphinxenv/Scripts/activate (windows)
source sphinx/bin/activate (linux)
pip install -r requirements.txt
or

Then run the CMake GUI from the terminal, with the Python env activated:
doxygen Doxyfile

cmake-gui
in the `docs/` directory.

Set the `WITH_DOCS` flag to true in the CMake GUI, then hit configure + generate.
Build, successively, the doxygen project and then the sphinx project.

**NOTE:** The sphinx project will fail its build if doxygen isn't built first.
If you do not, the Docs section (that uses doxygen) will display a warning of the form:
## Read the Docs

```
!Warning
oxygenclass: breathe_default_project value ‘OmniPhotos’ does not seem to be a valid key for the breathe_projects dictionary
```
Read the Docs virtual machines read the [sphinx](https://www.sphinx-doc.org/) `conf.py` file and generate the documentation accordingly.
We have injected the call to doxygen into this file.
The doxygen binary is then executed in the docs directory and generates files in the `docs/html/` directory, replacing the generated sphinx html files with those build by doxygen.

The Doxyfile.in is where you want to make your modifications to the html/xml output from Doxygen.
This will be copied over and filled in by CMake at build time.
To switch this on or off the html generation for doxygen set the `GENERATE_HTML` flag in `Doxyfile.in` and run the configure + generate pipeline again.
There is also a `HIDE_UNDOC_CLASSES` that will reduce the build time if set to "yes".
If you want the standard doxygen HTML files with all the classes, then set this flag to "no" as well as the `GENERATE_HTML` flag to "yes".
The latest generated code documentation is available at https://omniphotos.readthedocs.io/en/latest/.

To run the Doxygen section of the build on its own, run the following command in
the `build/docs` directory once you've run CMake:

doxygen ..build/docs/doxygen/Doxyfile
# Writing Documentation

In order to run the sphinx build step independently (once you've run the doxygen step successfully), run the following command from the `docs` directory:

sphinx-build -E -b html -Dbreathe_projects.OmniPhotos=../build/docs/doxygen/xml . ../build/docs/sphinx
## Getting started

In order to create a doxygen code stump, one can use the **Doxygen Comments** extension found in the Visual Studio online extension manager.
It is not necessary to use this, but it seems to be the easiest option:

<img src='images/vs_screenshot_1.png'/>

The extension will generate a stub whenever you type `/**` and press enter above a function, variable or class.

The stumps can be customized via Tools->Options and selecting Doxygen in the left-hand pane.

**Other Option:**
Use the Visual Studio Plugin **1-Click Docs**.
You can use the **1-Click Docs** extension to call `doxygen.exe` in Visual Studio.
For more information please refer to https://www.doxygen.nl/manual/starting.html.

There is a demo project (https://github.com/yuanmingze/codestyle_demo) for Doxygen use.


## Doxygen Conventions

### 1. C/C++

All documentation for classes should be located in the header files.

The convention that has been used for the documentation has been the javadoc style:

/**
* A brief history of JavaDoc-style (C-style) comments.
*
* This is the typical JavaDoc-style C-style comment. It starts with two
* asterisks.
*
* @param theory Even if there is only one possible unified theory. it is just
* a set of rules and equations.
*/
void cstyle(int theory);

The source code and further elaboration on this style can be found here:
https://www.doxygen.nl/manual/docblocks.html

Each class method should have a documentation string one line above it, as shown above.
The description for the function should be succinct and define what purpose of the function, the @param that are being used and why it is there.
If there is a @return value, this should be explained here as well.
The “@” symbol has been used to designate the fields.

Single line comments should be added before class variables as well:

/** List of supported rendering methods. */
std::vector<std::string> methods;

Note that for a class to appear as "documented" in the "Class Index" list and "Class Hiearchy" lists in Doxygen, one needs to add a `@brief` descriptor in the line directly before the class declaration (in the header).

/**
* @brief This is a class for ...
*/
class MyClass
{
}
The `@brief` notation is not strictly necessary here, but might be important to be explicit.


### 2. Python

**NOTE:**
- `-E` here tells sphinx to rebuild everything, no matter what (i.e does not do an incremental build)
- `-D` overrides the specified value in `conf.py` for var `breathe_projects.OmniPhotos`
- the last two arguments are positional for source and build dir respectively.
The convention of coding is based on the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html).

If you use Visual Studio Code, please refer to the official guide to configure the [automatic linting functionality](https://code.visualstudio.com/docs/python/linting).
21 changes: 15 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
copyright = '2020, Tobias Bertel, Mingze Yuan, Reuben Lindroos, Christian Richardt'
author = 'Tobias Bertel, Mingze Yuan, Reuben Lindroos, Christian Richardt'


import subprocess
subprocess.call("doxygen")
# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["breathe"]
# extensions = ["breathe"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -43,12 +44,20 @@
# 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 = 'sphinx_rtd_theme'

# 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']
# html_static_path = ['_static']

html_extra_path = ['html']

# html_context = {
# 'css_files': [
# '_static/theme_overides.css', # override wide tables in RTD theme
# ],
# }

# Breathe Configuration
breathe_default_project = "OmniPhotos"
# # Breathe Configuration
# breathe_default_project = "OmniPhotos"
Binary file added docs/images/vs_screenshot_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0e4c026

Please sign in to comment.