Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several targets #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required (VERSION 3.8)

project ("CatCutifier")
project ("cpp-documentation-example")

# Add the cmake folder so the FindSphinx module is found
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

add_subdirectory ("CatCutifier")
add_subdirectory ("src")
add_subdirectory ("docs")
26 changes: 17 additions & 9 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)

# Find all the public headers
get_target_property(CAT_CUTIFIER_PUBLIC_HEADER_DIR CatCutifier INTERFACE_INCLUDE_DIRECTORIES)
file(GLOB_RECURSE CAT_CUTIFIER_PUBLIC_HEADERS
${CAT_CUTIFIER_PUBLIC_HEADER_DIR}/*.h)

set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/CatCutifier)
set(DOXYGEN_INPUT_DIR_SRC ${PROJECT_SOURCE_DIR}/src)
set(DOXYGEN_INPUT_DIR_INCLUDE ${PROJECT_SOURCE_DIR}/include)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
Expand All @@ -18,9 +14,20 @@ configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
# Doxygen won't create this for us
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})

# Find all the public headers
file(GLOB_RECURSE project_include_headers ${PROJECT_SOURCE_DIR}/include/*.h ${PROJECT_SOURCE_DIR}/include/*.hpp)
file(GLOB_RECURSE project_src_headers ${PROJECT_SOURCE_DIR}/src/*.h ${PROJECT_SOURCE_DIR}/src/*.hpp)
# Filter out headers files in src/**/internal/ details/ private/ subfolders
list(FILTER project_src_headers EXCLUDE REGEX "\/internal\/")
list(FILTER project_src_headers EXCLUDE REGEX "\/details\/")
list(FILTER project_src_headers EXCLUDE REGEX "\/private\/")
set(project_headers ${project_include_headers} ${project_src_headers})
message("project_include_headers=${project_include_headers}")
message("project_headers=${project_headers}")

# Only regenerate Doxygen when the Doxyfile or public headers change
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
DEPENDS ${CAT_CUTIFIER_PUBLIC_HEADERS}
DEPENDS ${project_include_headers}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating docs"
Expand All @@ -29,6 +36,7 @@ add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
# Nice named target so we can run the job easily
add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})


set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR})
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx)
set(SPHINX_INDEX_FILE ${SPHINX_BUILD}/index.html)
Expand All @@ -41,10 +49,10 @@ add_custom_command(OUTPUT ${SPHINX_INDEX_FILE}
COMMAND
${SPHINX_EXECUTABLE} -b html
# Tell Breathe where to find the Doxygen output
-Dbreathe_projects.CatCutifier=${DOXYGEN_OUTPUT_DIR}/xml
-Dbreathe_projects.main_project=${DOXYGEN_OUTPUT_DIR}/xml
${SPHINX_SOURCE} ${SPHINX_BUILD}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
DEPENDS
# Other docs files you want to track should go here (or in some variable)
${CMAKE_CURRENT_SOURCE_DIR}/index.rst
${DOXYGEN_INDEX_FILE}
Expand Down
4 changes: 2 additions & 2 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,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 = "@DOXYGEN_INPUT_DIR_SRC@" "@DOXYGEN_INPUT_DIR_INCLUDE@"

# 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 @@ -888,7 +888,7 @@ FILE_PATTERNS = *.c \
# be searched for input files as well.
# The default value is: NO.

RECURSIVE = NO
RECURSIVE = YES

# The EXCLUDE tag can be used to specify files and/or directories that should be
# excluded from the INPUT source files. This way you can easily exclude a
Expand Down
19 changes: 12 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@

import subprocess, os

def configureDoxyfile(input_dir, output_dir):
def configureDoxyfile(top_dir, output_dir):

with open('Doxyfile.in', 'r') as file :
filedata = file.read()

filedata = filedata.replace('@DOXYGEN_INPUT_DIR@', input_dir)
input_dir_src = top_dir + "/src"
input_dir_include = top_dir + "/include"

filedata = filedata.replace('@DOXYGEN_INPUT_DIR_SRC@', input_dir_src)
filedata = filedata.replace('@DOXYGEN_INPUT_DIR_INCLUDE@', input_dir_include)
filedata = filedata.replace('@DOXYGEN_OUTPUT_DIR@', output_dir)

with open('Doxyfile', 'w') as file:
Expand All @@ -32,16 +36,16 @@ def configureDoxyfile(input_dir, output_dir):

breathe_projects = {}
if read_the_docs_build:
input_dir = '../CatCutifier'
top_dir = '../'
output_dir = 'build'
configureDoxyfile(input_dir, output_dir)
configureDoxyfile(top_dir, output_dir)
subprocess.call('doxygen', shell=True)
breathe_projects['CatCutifier'] = output_dir + '/xml'
breathe_projects['main_project'] = output_dir + '/xml'


# -- Project information -----------------------------------------------------

project = 'CatCutifier'
project = 'cat_cutifier'
copyright = '2019, Simon Brand'
author = 'Simon Brand'

Expand Down Expand Up @@ -79,4 +83,5 @@ def configureDoxyfile(input_dir, output_dir):
html_static_path = ['_static']

# Breathe Configuration
breathe_default_project = "CatCutifier"
breathe_default_project = "main_project"

23 changes: 22 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,26 @@ Welcome to CatCutifier's documentation!
Docs
====

Animals
-------

First we have some animals

.. doxygennamespace:: Animals
:members:

Cats
----

Enter the cats

.. doxygenstruct:: cat
:members:
:members:

Dogs
----

And the dogs

.. doxygenstruct:: dog
:members:
10 changes: 10 additions & 0 deletions include/animals/animals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Animals
{
enum Species
{
Cat,
Dog,
Cow
};
}
#endif //CPP_DOCUMENTATION_EXAMPLE_ANIMAL_H
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_subdirectory(cat)
add_subdirectory(dog)

1 change: 1 addition & 0 deletions src/cat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(cat_cutifier)
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/cat/cat_cutifier/internal/CatInternalHeader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Haaders in this folder are considered internal, ans will not be part of the doc.
// See doc/CMakeLists.txt: subfolders internal/ details/ and private/ are ignored
2 changes: 2 additions & 0 deletions src/dog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(dog_ugliflier)

4 changes: 4 additions & 0 deletions src/dog/dog_ugliflier/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_library (DogUglifier "DogUglifier.cpp" "DogUglifier.h")
target_include_directories(DogUglifier PUBLIC .)

# Should install library properly here, but I'm focusing on just the docs
4 changes: 4 additions & 0 deletions src/dog/dog_ugliflier/DogUglifier.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "DogUglifier.h"

void dog::make_ugly(){
}
11 changes: 11 additions & 0 deletions src/dog/dog_ugliflier/DogUglifier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

/**
An ugly dog
*/
struct dog {
/**
Make this dog ugly
*/
void make_ugly();
};