jsdoc cmake fixes

This commit is contained in:
Thijs Wenker 2018-01-22 17:59:01 +01:00
parent a31fe7546a
commit 483074b11e
5 changed files with 35 additions and 15 deletions

View file

@ -279,6 +279,9 @@ endif(UNIX)
# assume we are using a Qt build without bearer management
add_definitions(-DQT_NO_BEARERMANAGEMENT)
# require JSDoc to be build before interface is deployed (Console Auto-complete)
add_dependencies(${TARGET_NAME} jsdoc)
if (APPLE)
# link in required OS X frameworks and include the right GL headers
find_library(OpenGL OpenGL)
@ -299,6 +302,9 @@ if (APPLE)
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_SOURCE_DIR}/scripts"
"$<TARGET_FILE_DIR:${TARGET_NAME}>/../Resources/scripts"
COMMAND "${CMAKE_COMMAND}" -E copy
"${CMAKE_SOURCE_DIR}/tools/jsdoc/out/hifiJSDoc.json"
"$<TARGET_FILE_DIR:${TARGET_NAME}>/../Resources/auto-complete"
)
# call the fixup_interface macro to add required bundling commands for installation
@ -313,6 +319,9 @@ else (APPLE)
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_SOURCE_DIR}/scripts"
"$<TARGET_FILE_DIR:${TARGET_NAME}>/scripts"
COMMAND "${CMAKE_COMMAND}" -E copy
"${CMAKE_SOURCE_DIR}/tools/jsdoc/out/hifiJSDoc.json"
"$<TARGET_FILE_DIR:${TARGET_NAME}>/resources/auto-complete"
)
# link target to external libraries
@ -349,16 +358,6 @@ endif()
add_bugsplat()
# generate the JSDoc JSON for the JSConsole auto-completer
add_custom_command(TARGET ${TARGET_NAME} #POST_BUILD
COMMAND npm install
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tools/jsdoc
)
add_custom_command(TARGET ${TARGET_NAME}
COMMAND node_modules/.bin/jsdoc . -c config.json
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tools/jsdoc
)
if (WIN32)
set(EXTRA_DEPLOY_OPTIONS "--qmldir \"${PROJECT_SOURCE_DIR}/resources/qml\"")

View file

@ -2,6 +2,9 @@
add_subdirectory(scribe)
set_target_properties(scribe PROPERTIES FOLDER "Tools")
add_subdirectory(jsdoc)
set_target_properties(jsdoc PROPERTIES FOLDER "Tools")
if (BUILD_TOOLS)
add_subdirectory(udt-test)
set_target_properties(udt-test PROPERTIES FOLDER "Tools")
@ -27,4 +30,3 @@ if (BUILD_TOOLS)
add_subdirectory(auto-tester)
set_target_properties(auto-tester PROPERTIES FOLDER "Tools")
endif()

View file

@ -0,0 +1,14 @@
set(TARGET_NAME jsdoc)
add_custom_target(${TARGET_NAME})
SET(JSDOC_WORKING_DIR ${CMAKE_SOURCE_DIR}/tools/jsdoc)
file(TO_NATIVE_PATH ${JSDOC_WORKING_DIR}/node_modules/.bin/jsdoc JSDOC_PATH)
file(TO_NATIVE_PATH ${JSDOC_WORKING_DIR}/config.json JSDOC_CONFIG_PATH)
file(TO_NATIVE_PATH ${JSDOC_WORKING_DIR} NATIVE_JSDOC_WORKING_DIR)
add_custom_command(TARGET ${TARGET_NAME}
COMMAND (npm --no-progress install) & (${JSDOC_PATH} ${NATIVE_JSDOC_WORKING_DIR} -c ${JSDOC_CONFIG_PATH})
WORKING_DIRECTORY ${JSDOC_WORKING_DIR}
COMMENT "generate the JSDoc JSON for the JSConsole auto-completer"
)

View file

@ -10,6 +10,8 @@ function endsWith(path, exts) {
exports.handlers = {
beforeParse: function(e) {
const pathTools = require('path');
var rootFolder = pathTools.dirname(e.filename);
console.log("Scanning hifi source for jsdoc comments...");
// directories to scan for jsdoc comments
@ -34,9 +36,10 @@ exports.handlers = {
const fs = require('fs');
dirList.forEach(function (dir) {
var files = fs.readdirSync(dir)
var joinedDir = pathTools.join(rootFolder, dir);
var files = fs.readdirSync(joinedDir)
files.forEach(function (file) {
var path = dir + "/" + file;
var path = pathTools.join(joinedDir, file);
if (fs.lstatSync(path).isFile() && endsWith(path, exts)) {
var data = fs.readFileSync(path, "utf8");
var reg = /(\/\*\*jsdoc(.|[\r\n])*?\*\/)/gm;
@ -48,7 +51,7 @@ exports.handlers = {
});
});
fs.writeFile("out/hifiJSDoc.js", e.source, function(err) {
fs.writeFile(pathTools.join(rootFolder, "out/hifiJSDoc.js"), e.source, function(err) {
if (err) {
return console.log(err);
}

View file

@ -1,9 +1,11 @@
exports.handlers = {
processingComplete: function(e) {
const pathTools = require('path');
var rootFolder = pathTools.join(__dirname, '..');
var doclets = e.doclets.map(doclet => Object.assign({}, doclet));
const fs = require('fs');
doclets.map(doclet => {delete doclet.meta; delete doclet.comment});
fs.writeFile("out/hifiJSDoc.json", JSON.stringify(doclets, null, 4), function(err) {
fs.writeFile(pathTools.join(rootFolder, "out/hifiJSDoc.json"), JSON.stringify(doclets, null, 4), function(err) {
if (err) {
return console.log(err);
}