| 1 |
# check if the user wants to build ddocs |
|---|
| 2 |
# |
|---|
| 3 |
# Copyright (c) 2007 Tim Burrell <tim.burrell@gmail.com> |
|---|
| 4 |
# |
|---|
| 5 |
# All rights reserved. |
|---|
| 6 |
# |
|---|
| 7 |
# See Copyright.txt for details. |
|---|
| 8 |
# |
|---|
| 9 |
|
|---|
| 10 |
# Do not build documentation by default |
|---|
| 11 |
if (NOT CMAKE_D_BUILD_DOCS) |
|---|
| 12 |
set(CMAKE_D_BUILD_DOCS False CACHE BOOLEAN TRUE FORCE) |
|---|
| 13 |
else (NOT CMAKE_D_BUILD_DOCS) |
|---|
| 14 |
# check for specified ddoc files |
|---|
| 15 |
# default to the candydoc usual |
|---|
| 16 |
set(CMAKE_D_BUILD_DOCS True CACHE BOOLEAN FALSE FORCE) |
|---|
| 17 |
if (NOT CMAKE_D_DDOC_FILES) |
|---|
| 18 |
set(CMAKE_D_DDOC_FILES "documentation/candydoc/candy.ddoc;documentation/candydoc/modules.ddoc" CACHE STRING FALSE FORCE) |
|---|
| 19 |
else (NOT CMAKE_D_DDOC_FILES) |
|---|
| 20 |
set(CMAKE_D_DDOC_FILES "${CMAKE_D_DDOC_FILES}" CACHE STRING FALSE FORCE) |
|---|
| 21 |
endif (NOT CMAKE_D_DDOC_FILES) |
|---|
| 22 |
|
|---|
| 23 |
# copy the candydoc files |
|---|
| 24 |
file(GLOB_RECURSE CANDY_DOC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/candydoc/*") |
|---|
| 25 |
foreach(item ${CANDY_DOC_FILES}) |
|---|
| 26 |
string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" item ${item}) |
|---|
| 27 |
configure_file(${item} ${CMAKE_CURRENT_BINARY_DIR}/documentation/${item} COPYONLY) |
|---|
| 28 |
endforeach(item) |
|---|
| 29 |
|
|---|
| 30 |
# create modules.ddoc |
|---|
| 31 |
file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/*.d") |
|---|
| 32 |
set(first True) |
|---|
| 33 |
foreach(item ${sources}) |
|---|
| 34 |
# first make sure we're not config.d |
|---|
| 35 |
string(REGEX MATCH "config\\.d" ignore ${item}) |
|---|
| 36 |
if (NOT ${ignore} MATCHES "") |
|---|
| 37 |
# fix up the output |
|---|
| 38 |
string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" item ${item}) |
|---|
| 39 |
string(REGEX REPLACE "\\.d" ".html" htmlFile ${item}) |
|---|
| 40 |
string(REGEX REPLACE "^.*/" "" htmlFile ${htmlFile}) |
|---|
| 41 |
string(REGEX REPLACE "\\.d" "" item ${item}) |
|---|
| 42 |
string(REGEX REPLACE "/" "." item ${item}) |
|---|
| 43 |
if (first) |
|---|
| 44 |
set(modules "${item}") |
|---|
| 45 |
set(first False) |
|---|
| 46 |
set(CMAKE_D_DDOC_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/documentation/${htmlFile}" CACHE STRING FALSE FORCE) |
|---|
| 47 |
else (first) |
|---|
| 48 |
set(modules "${modules};${item}") |
|---|
| 49 |
set(CMAKE_D_DDOC_CLEAN_FILES "${CMAKE_D_DDOC_CLEAN_FILES}" "${CMAKE_CURRENT_BINARY_DIR}/documentation/${htmlFile}" CACHE STRING FALSE FORCE) |
|---|
| 50 |
endif (first) |
|---|
| 51 |
endif (NOT ${ignore} MATCHES "") |
|---|
| 52 |
endforeach(item) |
|---|
| 53 |
|
|---|
| 54 |
# create formatted modules string |
|---|
| 55 |
set(modString "MODULES = \n") |
|---|
| 56 |
foreach(item ${modules}) |
|---|
| 57 |
set(modString "${modString}\t$(MODULE ${item})\n") |
|---|
| 58 |
endforeach(item) |
|---|
| 59 |
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/documentation/candydoc/modules.ddoc" ${modString}) |
|---|
| 60 |
|
|---|
| 61 |
# create index.html |
|---|
| 62 |
set(modString "<html><head><title>${PROJECT_NAME} API Documentation</title></head><body>\n") |
|---|
| 63 |
set(modString "<h>${PROJECT_NAME} API Documentation:<br /></h>\n") |
|---|
| 64 |
set(modString "${modString}<ul>\n") |
|---|
| 65 |
foreach(item ${modules}) |
|---|
| 66 |
string(REGEX REPLACE "[a-z0-9]*\\." "" filename ${item}) |
|---|
| 67 |
set(modString "${modString}\t<li> <a href=\"${filename}.html\">${item}</a> </li>\n") |
|---|
| 68 |
endforeach(item) |
|---|
| 69 |
set(modString "${modString}</ul>\n") |
|---|
| 70 |
set(modString "${modString}</body></html>\n") |
|---|
| 71 |
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/documentation/index.html" ${modString}) |
|---|
| 72 |
endif (NOT CMAKE_D_BUILD_DOCS) |
|---|