Code Monkey home page Code Monkey logo

cpp_project's Introduction

cpp_project

A template setup for cpp project.

It contains the following:

  • CMake as a build tool
  • TravisCI for continuous integration
  • Google Tests for testing the project libraries
  • Google Benchmark for benchmarking the project libraries
  • Documentation on readthedocs.org built using Sphinx, Doxygen and breathe.

The template documentation for this project is on readthedocs.

Build Status

Platform

  • CMake
  • C++11
  • Clang
  • Linux (Xenial/Ubuntu 18.04)

Build

As prequisites, CMAKE and git needs to be already installed.

cd graphs
sh install.sh

Generating Documentation

To generate documentation on readthedocs.org, do the following:

  • On readthedocs.org, select your project for generating documentation and build.
cd docs
doxygen -g Doxyfile

Change the PROJECT_NAME in Doxyfile.

doxygen Doxyfile

Now let's do the sphinx part

sphinx-quickstart 

These are the prompts you get. We're going for a simple documentation setup here.

> Separate source and build directories (y/n) [n]: n
> Project name: python_project
> Author name(s): Wasim Akram Khan
> Project release []: 0.0.1
> Project language [en]: 

We have now setup the documentation

make html

To generate documentation locally each time you change the documentation:

cd docs
make clean
doxygen Doxyfile
make html

Open the docs/build/html/index.html in your browser to view the documentation on localhost.

Generating Documentation

cd docs
doxygen -g Doxyfile

Now change some things in the Doxyfile that you have just generated.

  • PROJECT_NAME = "python_project"
  • GENERATE_HTML = NO # (We don't need html output for readthedocs style docs)
  • GENERATE_LATEX = NO
doxygen Doxyfile
sphinx-quickstart

Then you'll get some prompts.

> Separate source and build directories (y/n) [n]: y
> Project name: python_project
> Author name(s): Wasim Akram Khan
> Project release []: 0.0.1
> Project language [en]: 

You can see there are four files insides docs/source generated by sphinx: _static, _templates, conf.py, index.rst

The conf.py file defines how your source files are documented. You need to add the path of your package so that its files are reachable from conf.py.

Path of my conf.py: docs/source/conf.py

Add these two statements so conf.py can access your package.

import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath('../..'))

Extension tell doc generator what kind of stuffs to document and what not. For instance, sphinx.ext.viewcode provides link to the code code. Add the following to conf.py

# First two are essential to generate the docs, others are optional.
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.viewcode',
    'sphinx.ext.doctest',
    'sphinx.ext.intersphinx',
    'sphinx.ext.todo',
    'sphinx.ext.ifconfig',
    'sphinx.ext.githubpages',
]

We're done with the configuration. See the source code for conf.py. I have done away with the boilerplate stuff and

docs/source/index.rst file is like the readme for the documentation. The changes you make to this file is seen in your documentation. In this file you define which python source file to document and which not to. You can include installation instructions, features, usage code snippets, etc in this file.

We built two libraries in this project: mathlib and strlib. We want both to be documented. So let's add that to the index.rst above "Indices and tables".

Math Lib
========
.. automodule:: python_project.mathlib
   :members:

String Lib
==========
.. automodule:: python_project.strlib
   :members:

View the source code for index.rst. I have done away with the boilerplate stuff and made the documentation more custom.

make html

We have now setup the documentation. Open the docs/build/html/index.html in your browser to view the documentation on localhost.

If you're not seeing your source files indexed/documented then it's probably path error. Make sure your source files are discoverable.

You can do this by testing different values for sys.path.insert()

To re-generate documentation locally each time you change the documentation:

cd docs
make clean
doxygen Doxyfile
make html

Open the docs/build/html/index.html in your browser to view the documentation on localhost.

cpp_project's People

Contributors

wasimusu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.