Adding dedent

This commit is contained in:
milad nazeri 2018-04-28 12:16:39 -07:00
commit 91c0fa2778
53 changed files with 454 additions and 226 deletions

View file

@ -18,6 +18,10 @@
/**jsdoc
* This API helps manage adding and deleting avatar bookmarks.
* @namespace AvatarBookmarks
*
* @hifi-interface
* @hifi-client-entity
*
*/
class AvatarBookmarks: public Bookmarks, public Dependency {

View file

@ -10,8 +10,11 @@
//
/**jsdoc
* The LOD class manages your Level of Detail functions within interface
* The LODManager API manages your Level of Detail functions within interface.
* @namespace LODManager
*
* @hifi-interface
* @hifi-client-entity
*/
#ifndef hifi_LODManager_h

View file

@ -24,6 +24,9 @@
/**jsdoc
* @namespace SpeechRecognizer
*
* @hifi-interface
* @hifi-client-entity
*/
class SpeechRecognizer : public QObject, public Dependency {
Q_OBJECT

View file

@ -28,6 +28,10 @@ class AudioScope : public QObject, public Dependency {
/**jsdoc
* The AudioScope API helps control the Audio Scope features in Interface
* @namespace AudioScope
*
* @hifi-interface
* @hifi-client-entity
*
* @property {number} scopeInput <em>Read-only.</em>
* @property {number} scopeOutputLeft <em>Read-only.</em>
* @property {number} scopeOutputRight <em>Read-only.</em>

View file

@ -30,6 +30,9 @@
/**jsdoc
* The AvatarManager API has properties and methods which manage Avatars within the same domain.
* @namespace AvatarManager
*
* @hifi-interface
* @hifi-client-entity
*/
class AvatarManager : public AvatarHashMap {

View file

@ -29,6 +29,9 @@
/**jsdoc
* The FaceTracker API helps manage facial tracking hardware.
* @namespace FaceTracker
*
* @hifi-interface
* @hifi-client-entity
*/
class DdeFaceTracker : public FaceTracker, public Dependency {

View file

@ -18,6 +18,10 @@
* The Picks API lets you create and manage objects for repeatedly calculating intersections in different ways.
*
* @namespace Picks
*
* @hifi-interface
* @hifi-client-entity
*
* @property PICK_NOTHING {number} A filter flag. Don't intersect with anything.
* @property PICK_ENTITIES {number} A filter flag. Include entities when intersecting.
* @property PICK_OVERLAYS {number} A filter flag. Include overlays when intersecting.

View file

@ -19,6 +19,9 @@
* Pointers can also be configured to automatically generate PointerEvents.
*
* @namespace Pointers
*
* @hifi-interface
* @hifi-client-entity
*/
class PointerScriptingInterface : public QObject, public Dependency {

View file

@ -38,6 +38,9 @@ class AccountServicesScriptingInterface : public QObject {
/**jsdoc
* The AccountServices API contains helper functions related to user connectivity
*
* @hifi-interface
* @hifi-client-entity
*
* @namespace AccountServices
* @property {string} username <em>Read-only.</em>
* @property {boolean} loggedIn <em>Read-only.</em>

View file

@ -27,8 +27,14 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable {
/**jsdoc
* The Audio API features tools to help control audio contexts and settings.
*
*
* @namespace Audio
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*
* @property {boolean} muted
* @property {boolean} noiseReduction
* @property {number} inputVolume

View file

@ -21,6 +21,9 @@
* The Clipboard API enables you to export and import entities to and from JSON files.
*
* @namespace Clipboard
*
* @hifi-interface
* @hifi-client-entity
*/
class ClipboardScriptingInterface : public QObject {
Q_OBJECT

View file

@ -145,7 +145,10 @@ class ScriptEngine;
*
* @namespace Controller
*
* @property {Controller.Actions} Actions - Predefined actions on Interface and the user's avatar. These can be used as end
* @hifi-interface
* @hifi-client-entity
*
* @property {Controller.Actions} Actions - Predefined actions on Interface and the user's avatar. These can be used as end
* points in a {@link RouteObject} mapping. A synonym for <code>Controller.Hardware.Actions</code>.
* <em>Read-only.</em><br />
* Default mappings are provided from the <code>Controller.Hardware.Keyboard</code> and <code>Controller.Standard</code> to

View file

@ -18,6 +18,9 @@
/**jsdoc
* The GooglePoly API allows you to interact with Google Poly models direct from inside High Fidelity.
* @namespace GooglePoly
*
* @hifi-interface
* @hifi-client-entity
*/
class GooglePolyScriptingInterface : public QObject, public Dependency {

View file

@ -28,7 +28,11 @@ class QScriptEngine;
* The HMD API provides access to the HMD used in VR display mode.
*
* @namespace HMD
* @property {Vec3} position - The position of the HMD if currently in VR display mode, otherwise
*
* @hifi-interface
* @hifi-client-entity
*
* @property {Vec3} position - The position of the HMD if currently in VR display mode, otherwise
* {@link Vec3(0)|Vec3.ZERO}. <em>Read-only.</em>
* @property {Quat} orientation - The orientation of the HMD if currently in VR display mode, otherwise
* {@link Quat(0)|Quat.IDENTITY}. <em>Read-only.</em>

View file

@ -32,6 +32,9 @@ class MenuItemProperties;
* If a menu item doesn't belong to a group it is always displayed.
*
* @namespace Menu
*
* @hifi-interface
* @hifi-client-entity
*/
/**

View file

@ -86,6 +86,9 @@ protected:
* The <code>Selection</code> API provides a means of grouping together avatars, entities, and overlays in named lists.
* @namespace Selection
*
* @hifi-interface
* @hifi-client-entity
*
* @example <caption>Outline an entity when it is grabbed by a controller.</caption>
* // Create a box and copy the following text into the entity's "Script URL" field.
* (function () {

View file

@ -18,6 +18,9 @@
/**jsdoc
* The Settings API provides a facility to store and retrieve values that persist between Interface runs.
* @namespace Settings
*
* @hifi-interface
* @hifi-client-entity
*/
class SettingsScriptingInterface : public QObject {

View file

@ -28,7 +28,11 @@
* physics.
*
* @namespace Window
* @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other
*
* @hifi-interface
* @hifi-client-entity
*
* @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other
* chrome), in pixels. <em>Read-only.</em>
* @property {number} innerHeight - The height of the drawable area of the Interface window (i.e., without borders or other
* chrome), in pixels. <em>Read-only.</em>

View file

@ -26,6 +26,10 @@ class AvatarInputs : public QObject {
/**jsdoc
* API to help manage your Avatar's input
* @namespace AvatarInputs
*
* @hifi-interface
* @hifi-client-entity
*
* @property {boolean} cameraEnabled <em>Read-only.</em>
* @property {boolean} cameraMuted <em>Read-only.</em>
* @property {boolean} isHMD <em>Read-only.</em>

View file

@ -31,9 +31,6 @@
#include "EntityTree.h"
#include "ContextOverlayLogging.h"
/**jsdoc
* @namespace ContextOverlay
*/
class ContextOverlayInterface : public QObject, public Dependency {
Q_OBJECT

View file

@ -76,6 +76,10 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R
* The Overlays API provides facilities to create and interact with overlays. Overlays are 2D and 3D objects visible only to
* yourself and that aren't persisted to the domain. They are used for UI.
* @namespace Overlays
*
* @hifi-interface
* @hifi-client-entity
*
* @property {Uuid} keyboardFocusOverlay - Get or set the {@link Overlays.OverlayType|web3d} overlay that has keyboard focus.
* If no overlay has keyboard focus, get returns <code>null</code>; set to <code>null</code> or {@link Uuid|Uuid.NULL} to
* clear keyboard focus.

View file

@ -37,6 +37,10 @@ public:
* API to manage animation cache resources.
* @namespace AnimationCache
*
* @hifi-interface
* @hifi-client-entity
* @hifi-assignment-client
*
* @property {number} numTotal - Total number of total resources. <em>Read-only.</em>
* @property {number} numCached - Total number of cached resource. <em>Read-only.</em>
* @property {number} sizeTotal - Size in bytes of all resources. <em>Read-only.</em>

View file

@ -41,6 +41,10 @@ class AudioStreamStatsInterface : public QObject {
/**jsdoc
* @class AudioStats.AudioStreamStats
*
* @hifi-interface
* @hifi-client-entity
*
* @property {number} lossRate <em>Read-only.</em>
* @property {number} lossCount <em>Read-only.</em>
* @property {number} lossRateWindow <em>Read-only.</em>
@ -185,6 +189,10 @@ class AudioStatsInterface : public QObject {
/**jsdoc
* Audio stats from the client.
* @namespace AudioStats
*
* @hifi-interface
* @hifi-client-entity
*
* @property {number} pingMs <em>Read-only.</em>
* @property {number} inputReadMsMax <em>Read-only.</em>
* @property {number} inputUnplayedMsMax <em>Read-only.</em>

View file

@ -29,6 +29,11 @@ public:
* API to manage sound cache resources.
* @namespace SoundCache
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*
* @property {number} numTotal - Total number of total resources. <em>Read-only.</em>
* @property {number} numCached - Total number of cached resource. <em>Read-only.</em>
* @property {number} sizeTotal - Size in bytes of all resources. <em>Read-only.</em>

View file

@ -49,9 +49,12 @@ class UserInputMapper;
* output that already has a route the new route is ignored.</li>
* <li>New mappings override previous mappings: each output is processed using the route in the most recently enabled
* mapping that contains that output.</li>
* </p>
* </ul>
*
* @class MappingObject
*
* @hifi-interface
* @hifi-client-entity
*/
/**jsdoc

View file

@ -35,6 +35,9 @@ class ScriptingInterface;
* types.<p>
*
* @class RouteObject
*
* @hifi-interface
* @hifi-client-entity
*/
// TODO migrate functionality to a RouteBuilder class and make the proxy defer to that

View file

@ -174,6 +174,10 @@ private:
/**jsdoc
* @namespace Reticle
*
* @hifi-interface
* @hifi-client-entity
*
* @property {boolean} allowMouseCapture
* @property {number} depth
* @property {Vec2} maximumPosition

View file

@ -94,6 +94,12 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
* Interface has displayed and so knows about.
*
* @namespace Entities
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*
* @property {Uuid} keyboardFocusEntity - Get or set the {@link Entities.EntityType|Web} entity that has keyboard focus.
* If no entity has keyboard focus, get returns <code>null</code>; set to <code>null</code> or {@link Uuid|Uuid.NULL} to
* clear keyboard focus.

View file

@ -24,6 +24,9 @@
/**jsdoc
* The experimental Graphics API <em>(experimental)</em> lets you query and manage certain graphics-related structures (like underlying meshes and textures) from scripting.
* @namespace Graphics
*
* @hifi-interface
* @hifi-client-entity
*/
class GraphicsScriptingInterface : public QObject, public QScriptable, public Dependency {

View file

@ -144,6 +144,9 @@ public:
* API to manage model cache resources.
* @namespace ModelCache
*
* @hifi-interface
* @hifi-client-entity
*
* @property {number} numTotal - Total number of total resources. <em>Read-only.</em>
* @property {number} numCached - Total number of cached resource. <em>Read-only.</em>
* @property {number} sizeTotal - Size in bytes of all resources. <em>Read-only.</em>

View file

@ -151,6 +151,9 @@ public:
* API to manage texture cache resources.
* @namespace TextureCache
*
* @hifi-interface
* @hifi-client-entity
*
* @property {number} numTotal - Total number of total resources. <em>Read-only.</em>
* @property {number} numCached - Total number of cached resource. <em>Read-only.</em>
* @property {number} sizeTotal - Size in bytes of all resources. <em>Read-only.</em>

View file

@ -33,6 +33,11 @@ const QString GET_PLACE = "/api/v1/places/%1";
* The location API provides facilities related to your current location in the metaverse.
*
* @namespace location
*
* @hifi-interface
* @hifi-client-entity
* @hifi-assignment-client
*
* @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid|Uuid.NULL} if you're not
* connected to the domain or are in a serverless domain.
* <em>Read-only.</em>

View file

@ -37,6 +37,11 @@
* </ul>
*
* @namespace Messages
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*/
class MessagesClient : public QObject, public Dependency {
Q_OBJECT

View file

@ -89,6 +89,12 @@ class ScriptableResource : public QObject {
/**jsdoc
* @constructor Resource
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*
* @property {string} url - URL of this resource.
* @property {Resource.State} state - Current loading state.
*/

View file

@ -27,6 +27,11 @@
/**jsdoc
* The Assets API allows you to communicate with the Asset Browser.
* @namespace Assets
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*/
class AssetScriptingInterface : public BaseAssetScriptingInterface, QScriptable {
Q_OBJECT

View file

@ -35,6 +35,12 @@
* of gimbal lock.
* @namespace Quat
* @variation 0
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*
* @property IDENTITY {Quat} <code>{ x: 0, y: 0, z: 0, w: 1 }</code> : The identity rotation, i.e., no rotation.
* <em>Read-only.</em>
* @example <caption>Print the <code>IDENTITY</code> value.</caption>

View file

@ -25,6 +25,10 @@ class QScriptValue;
/**jsdoc
* @namespace Recording
*
* @hifi-interface
* @hifi-client-entity
* @hifi-assignment-client
*/
class RecordingScriptingInterface : public QObject, public Dependency {
Q_OBJECT

View file

@ -112,6 +112,10 @@ namespace SceneScripting {
/**jsdoc
* @class Scene.Stage
*
* @hifi-interface
* @hifi-client-entity
*
* @property {string} backgroundMode
* @property {Scene.Stage.KeyLight} keyLight
* @property {Scene.Stage.Location} location
@ -171,6 +175,10 @@ namespace SceneScripting {
/**jsdoc
* @namespace Scene
*
* @hifi-interface
* @hifi-client-entity
*
* @property {boolean} shouldRenderAvatars
* @property {boolean} shouldRenderEntities
* @property {Scene.Stage} stage

View file

@ -89,6 +89,12 @@ public:
/**jsdoc
* @namespace Script
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*
* @property {string} context
*/
class ScriptEngine : public BaseScriptEngine, public EntitiesScriptEngineProvider {

View file

@ -29,6 +29,10 @@ class ScriptEngine;
/**jsdoc
* @namespace ScriptDiscoveryService
*
* @hifi-interface
* @hifi-client-entity
*
* @property {string} debugScriptUrl
* @property {string} defaultScriptsPath
* @property {ScriptsModel} scriptsModel

View file

@ -23,6 +23,12 @@
* hexadecimal digits.
*
* @namespace Uuid
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*
* @property NULL {Uuid} The null UUID, <code>{00000000-0000-0000-0000-000000000000}</code>.
*/

View file

@ -68,6 +68,9 @@ public:
* <p>Has properties and functions below in addition to those of <a href="http://doc.qt.io/qt-5/qabstractitemmodel.html">
* http://doc.qt.io/qt-5/qabstractitemmodel.html</a>.</p>
* @class ScriptsModel
*
* @hifi-interface
* @hifi-client-entity
*/
class ScriptsModel : public QAbstractItemModel {
Q_OBJECT

View file

@ -20,6 +20,9 @@
* <p>Has properties and functions per <a href="http://doc.qt.io/qt-5/qsortfilterproxymodel.html">
* http://doc.qt.io/qt-5/qsortfilterproxymodel.html</a>.</p>
* @class ScriptsModelFilter
*
* @hifi-interface
* @hifi-client-entity
*/
class ScriptsModelFilter : public QSortFilterProxyModel {
Q_OBJECT

View file

@ -18,7 +18,12 @@
/**jsdoc
* @namespace Users
* @property {boolean} canKick - <code>true</code> if the domain server allows the node or avatar to kick (ban) avatars,
*
* @hifi-interface
* @hifi-client-entity
* @hifi-assignment-client
*
* @property {boolean} canKick - <code>true</code> if the domain server allows the node or avatar to kick (ban) avatars,
* otherwise <code>false</code>. <em>Read-only.</em>
* @property {boolean} requestsDomainListData - <code>true</code> if the avatar requests extra data from the mixers (such as
* positional data of an avatar you've ignored). <em>Read-only.</em>

View file

@ -47,6 +47,12 @@
*
* @namespace Vec3
* @variation 0
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*
* @property {Vec3} UNIT_X - <code>{ x: 1, y: 0, z: 0 }</code> : Unit vector in the x-axis direction. <em>Read-only.</em>
* @property {Vec3} UNIT_Y - <code>{ x: 0, y: 1, z: 0 }</code> : Unit vector in the y-axis direction. <em>Read-only.</em>
* @property {Vec3} UNIT_Z - <code>{ x: 0, y: 0, z: 1 }</code> : Unit vector in the z-axis direction. <em>Read-only.</em>

View file

@ -25,6 +25,11 @@
* Helper functions to render ephemeral debug markers and lines.
* DebugDraw markers and lines are only visible locally, they are not visible by other users.
* @namespace DebugDraw
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*/
class DebugDraw : public QObject {
Q_OBJECT

View file

@ -22,6 +22,10 @@
* The Paths API provides absolute paths to the scripts and resources directories.
*
* @namespace Paths
*
* @hifi-interface
* @hifi-client-entity
*
* @deprecated The Paths API is deprecated. Use {@link Script.resolvePath} and {@link Script.resourcesPath} instead.
* @readonly
* @property {string} defaultScripts - The path to the scripts directory. <em>Read-only.</em>

View file

@ -361,6 +361,12 @@ using MeshPointer = std::shared_ptr<graphics::Mesh>;
/**jsdoc
* A handle for a mesh in an entity, such as returned by {@link Entities.getMeshes}.
* @class MeshProxy
*
* @hifi-interface
* @hifi-client-entity
* @hifi-server-entity
* @hifi-assignment-client
*
* @deprecated Use the {@link Graphics} API instead.
*/
class MeshProxy : public QObject {

View file

@ -40,6 +40,10 @@ class Camera : public QObject {
* The Camera API provides access to the "camera" that defines your view in desktop and HMD display modes.
*
* @namespace Camera
*
* @hifi-interface
* @hifi-client-entity
*
* @property position {Vec3} The position of the camera. You can set this value only when the camera is in independent mode.
* @property orientation {Quat} The orientation of the camera. You can set this value only when the camera is in independent
* mode.

View file

@ -40,6 +40,9 @@ class OffscreenQmlSurface;
/**jsdoc
* @namespace Tablet
*
* @hifi-interface
* @hifi-client-entity
*/
class TabletScriptingInterface : public QObject, public Dependency {
Q_OBJECT
@ -176,6 +179,10 @@ Q_DECLARE_METATYPE(TabletButtonsProxyModel*);
/**jsdoc
* @class TabletProxy
*
* @hifi-interface
* @hifi-client-entity
*
* @property {string} name - Name of this tablet. <em>Read-only.</em>
* @property {boolean} toolbarMode - Used to transition this tablet into and out of toolbar mode.
* When tablet is in toolbar mode, all its buttons will appear in a floating toolbar.
@ -410,6 +417,10 @@ Q_DECLARE_METATYPE(TabletProxy*);
/**jsdoc
* @class TabletButtonProxy
*
* @hifi-interface
* @hifi-client-entity
*
* @property {Uuid} uuid - Uniquely identifies this button. <em>Read-only.</em>
* @property {TabletButtonProxy.ButtonProperties} properties
*/

View file

@ -1,243 +1,259 @@
const htmlclean = require('htmlclean');
const fs = require('fs');
const path = require('path');
const pretty = require('pretty');
const cheerio = require('cheerio');
const rimraf = require('rimraf');
// Dependencies
const htmlclean = require('htmlclean');
const fs = require('fs');
const path = require('path');
const pretty = require('pretty');
const cheerio = require('cheerio');
const rimraf = require('rimraf');
// required directories
let dir_out = path.join(__dirname, 'out');
// Required directories
let dir_out = path.join(__dirname, 'out');
let dir_grav = path.join(dir_out, 'grav');
let dir_css = path.join(dir_grav, 'css');
let dir_js = path.join(dir_grav, 'js');
let dir_template = path.join(dir_grav, 'templates');
let dir_grav = path.join(dir_out, 'grav');
let dir_css = path.join(dir_grav, 'css');
let dir_js = path.join(dir_grav, 'js');
let dir_template = path.join(dir_grav, 'templates');
let dir_md = path.join(dir_grav, '06.api-reference');
let dir_md_objects = path.join(dir_md, '02.Objects');
let dir_md_namespaces = path.join(dir_md, '01.Namespaces');
let dir_md_globals = path.join(dir_md, '03.Globals');
let dir_md = path.join(dir_grav, '06.api-reference');
let dir_md_objects = path.join(dir_md, '02.Objects');
let dir_md_namespaces = path.join(dir_md, '01.Namespaces');
let dir_md_globals = path.join(dir_md, '03.Globals');
// maps for sorting
let map_dir_md = {
"Class": dir_md_objects,
"Namespace": dir_md_namespaces,
"Global": dir_md_globals,
}
// Target Copy Directories
let targetTemplateDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav/user/themes/learn2/";
let targetMDDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav-content/";
// html variables to be replaced
const html_reg_static = /<span class="type-signature">\(static\)<\/span>/g
const html_reg_title = /\<h1.+?\>.+?\<\/h1\>/g;
const html_reg_htmlExt = /\.html/g;
// Array to itterate over and create if doesn't exist
let dirArray = [dir_grav, dir_css, dir_js, dir_template, dir_md, dir_md_objects, dir_md_namespaces, dir_md_globals];
// remove grav directory if exists to make sure old files aren't kept
if (fs.existsSync(dir_grav)){
console.log("dir_grav exists");
rimraf.sync(dir_grav);
}
// array to itterate over and create if doesn't exist
let dirArray = [dir_grav, dir_css, dir_js, dir_template, dir_md, dir_md_objects, dir_md_namespaces, dir_md_globals];
dirArray.forEach(function(dir){
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
// Maps for directory names
let map_dir_md = {
"API-Reference": dir_md,
"Globals": dir_md_globals,
"Objects": dir_md_objects,
"Namespaces": dir_md_namespaces,
"Class": dir_md_objects,
"Namespace": dir_md_namespaces,
"Global": dir_md_globals
}
})
function createMD(title, directory){
let mdSource = makeMdSource(title);
let destinationMDFile = path.join(directory, `API_${title}.md`);
fs.writeFileSync(destinationMDFile, mdSource);
}
// Base Grouping Directories for MD files
let baseMDDirectories = ["API-Reference", "Globals", "Namespaces", "Objects"]
function createTemplate(title,directory, content ){
let twigBasePartial = makeTwigFile(content);
let destinationFile = path.join(directory, `API_${title}.html.twig`);
fs.writeFileSync(destinationFile, twigBasePartial);
}
// Html variables to be handle regex replacements
const html_reg_static = /<span class="type-signature">\(static\)<\/span>/g
const html_reg_title = /\<h1.+?\>.+?\<\/h1\>/g;
const html_reg_htmlExt = /\.html/g;
const html_reg_objectHeader = /<header>[\s\S]+?<\/header>/;
const html_reg_objectSpanNew = /<h4 class="name"[\s\S]+?<\/span><\/h4>/;
createMD("API-Reference", dir_md);
createTemplate("API-Reference", dir_template,"");
createMD("Globals", dir_md_globals);
createTemplate("Globals", dir_template,"");
createMD("Namespaces", dir_md_namespaces);
createTemplate("Namespaces", dir_template,"");
createMD("Objects", dir_md_objects);
createTemplate("Objects", dir_template,"");
// read jsdoc output folder
let files = fs.readdirSync(dir_out);
files.forEach(function (file){
let curSource = path.join(dir_out, file);
if (path.extname(curSource) == ".html" && path.basename(curSource, '.html') !== "index") {
// clean up the html source
let loadedHtml = prepareHtml(curSource);
// extract the title, groupename, and the main div
let splitTitle = loadedHtml("title").text().split(": ");
// console.log(splitTitle);
let groupName = splitTitle[1];
let htmlTitle = splitTitle.pop();
// strip out undesired regex
let mainDiv = loadedHtml("#main").html();
let mainDivRegexed = mainDiv.replace(html_reg_static,"")
.replace(html_reg_title,"")
.replace(html_reg_htmlExt,"")
// create the .md file and corresponding folder
if (htmlTitle !== "Global"){
let mdSource = makeMdSource(htmlTitle);
let destinationDirectory = path.join(map_dir_md[groupName], htmlTitle);
if (!fs.existsSync(destinationDirectory)) {
fs.mkdirSync(destinationDirectory);
// Procedural functions
function createMD(title, directory, needsDir){
let mdSource = makeMdSource(title);
if (needsDir){
if (!fs.existsSync(directory)) {
fs.mkdirSync(directory);
}
let destinationMDFile = path.join(destinationDirectory, `API_${htmlTitle}.md`);
fs.writeFileSync(destinationMDFile, mdSource);
} else {
let mdSource = makeMdSource(htmlTitle);
let destinationMDFile = path.join(map_dir_md[groupName], `API_Globals.md`);
fs.writeFileSync(destinationMDFile, mdSource);
}
let destinationMDFile = path.join(directory, `API_${title}.md`);
fs.writeFileSync(destinationMDFile, mdSource);
}
// create the twig template
let twigBasePartial = makeTwigFile(mainDivRegexed);
let destinationFile = path.join(dir_template, `API_${htmlTitle}.html.twig`);
function createTemplate(title,content){
let twigBasePartial = makeTwigFile(content);
let destinationFile = path.join(dir_template, `API_${title}.html.twig`);
fs.writeFileSync(destinationFile, twigBasePartial);
}
})
// let curSource = path.join(dir_out, "Camera.html");
function copyFileSync( source, target ) {
let targetFile = target;
// If target is a directory a new file with the same name will be created
if ( fs.existsSync( target ) ) {
// console.log("target exists");
if ( fs.lstatSync( target ).isDirectory() ) {
// console.log("target is a directory");
targetFile = path.join( target, path.basename( source ) );
}
}
function prepareHtml(source){
let htmlBefore = fs.readFileSync(source, {encoding: 'utf8'});
let htmlAfter = htmlclean(htmlBefore);
let htmlAfterPretty = pretty(htmlAfter);
return cheerio.load(htmlAfterPretty);
}
function makeMdSource(title){
return (
`---
title: '${title}'
taxonomy:
category:
- docs
visible: true
---
`
)
}
function makeTwigFile(contentHtml){
return (
`
{% extends 'partials/base_noGit.html.twig' %}
{% set tags = page.taxonomy.tag %}
{% if tags %}
{% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs', 'tag': tags}},'order': {'by': 'default', 'dir': 'asc'}}) %}
{% else %}
{% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs'}},'order': {'by': 'default', 'dir': 'asc'}}) %}
{% endif %}
{% block navigation %}
<div id="navigation">
{% if not progress.isFirst(page.path) %}
<a class="nav nav-prev" href="{{ progress.nextSibling(page.path).url }}"> <img src="{{ url('theme://images/left-arrow.png') }}"></a>
{% endif %}
{% if not progress.isLast(page.path) %}
<a class="nav nav-next" href="{{ progress.prevSibling(page.path).url }}"><img src="{{ url('theme://images/right-arrow.png') }}"></a>
{% endif %}
</div>
{% endblock %}
{% block content %}
<div id="body-inner">
<h1>{{ page.title }}</h1>
${contentHtml}
</div>
{% endblock %}
`
)
}
let targertTwigDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav/user/themes/learn2/";
let targetMDDirectory = "D:/ROLC/Organize/O_Projects/Hifi/Docs/hifi-docs-grav-content/";
// Copy files to the Twig Directory
let templateFiles = fs.readdirSync(path.resolve(targertTwigDirectory));
templateFiles.forEach(function(file){
let curSource = path.join(targertTwigDirectory, file);
if(path.basename(file, '.html').indexOf("API") > -1){
fs.unlink(curSource);
fs.writeFileSync(targetFile, fs.readFileSync(source));
}
})
copyFolderRecursiveSync(dir_template, targertTwigDirectory);
function copyFolderRecursiveSync( source, target ) {
var files = [];
// Copy files to the Md Directory
// Check if folder needs to be created or integrated
var targetFolder = path.join( target, path.basename( source ) );
if ( !fs.existsSync( targetFolder ) ) {
fs.mkdirSync( targetFolder );
}
let baseMdRefDir = path.join(targetMDDirectory,"06.api-reference");
if (fs.existsSync(baseMdRefDir)){
rimraf.sync(baseMdRefDir);
}
copyFolderRecursiveSync(dir_md, targetMDDirectory);
// helper functions
function copyFileSync( source, target ) {
console.log("sourece:" + source);
let targetFile = target;
//if target is a directory a new file with the same name will be created
if ( fs.existsSync( target ) ) {
console.log("target exists");
if ( fs.lstatSync( target ).isDirectory() ) {
console.log("target is a directory");
targetFile = path.join( target, path.basename( source ) );
console.log("targetFile:" + targetFile);
// Copy
if ( fs.lstatSync( source ).isDirectory() ) {
files = fs.readdirSync( source );
files.forEach( function ( file ) {
var curSource = path.join( source, file );
if ( fs.lstatSync( curSource ).isDirectory() ) {
copyFolderRecursiveSync( curSource, targetFolder );
} else {
copyFileSync( curSource, targetFolder );
}
} );
}
}
fs.writeFileSync(targetFile, fs.readFileSync(source));
}
function copyFolderRecursiveSync( source, target ) {
var files = [];
//check if folder needs to be created or integrated
// console.log("target:" + target)
// console.log("source:" + source)
// console.log("basename source:" + path.basename( source ))
var targetFolder = path.join( target, path.basename( source ) );
// console.log("targetFolder:" + targetFolder);
if ( !fs.existsSync( targetFolder ) ) {
fs.mkdirSync( targetFolder );
function prepareHtml(source){
let htmlBefore = fs.readFileSync(source, {encoding: 'utf8'});
let htmlAfter = htmlclean(htmlBefore);
let htmlAfterPretty = pretty(htmlAfter);
return cheerio.load(htmlAfterPretty);
}
//copy
if ( fs.lstatSync( source ).isDirectory() ) {
files = fs.readdirSync( source );
files.forEach( function ( file ) {
var curSource = path.join( source, file );
if ( fs.lstatSync( curSource ).isDirectory() ) {
copyFolderRecursiveSync( curSource, targetFolder );
} else {
copyFileSync( curSource, targetFolder );
}
} );
function makeMdSource(title){
return (
`---
title: '${title}'
taxonomy:
category:
- docs
visible: true
---
`
)
}
}
function makeTwigFile(contentHtml){
return (
`
{% extends 'partials/base_noGit.html.twig' %}
{% set tags = page.taxonomy.tag %}
{% if tags %}
{% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs', 'tag': tags}},'order': {'by': 'default', 'dir': 'asc'}}) %}
{% else %}
{% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs'}},'order': {'by': 'default', 'dir': 'asc'}}) %}
{% endif %}
{% block navigation %}
<div id="navigation">
{% if not progress.isFirst(page.path) %}
<a class="nav nav-prev" href="{{ progress.nextSibling(page.path).url }}"> <img src="{{ url('theme://images/left-arrow.png') }}"></a>
{% endif %}
{% if not progress.isLast(page.path) %}
<a class="nav nav-next" href="{{ progress.prevSibling(page.path).url }}"><img src="{{ url('theme://images/right-arrow.png') }}"></a>
{% endif %}
</div>
{% endblock %}
{% block content %}
<div id="body-inner">
<h1>{{ page.title }}</h1>
${contentHtml}
</div>
{% endblock %}
`
)
}
function handleNamespace(title, content){
let destinationDirectory = path.join(map_dir_md["Namespace"], title);
createMD(title, destinationDirectory, true);
createTemplate(title, content);
}
function handleClass(title, content){
let destinationDirectory = path.join(map_dir_md["Class"], title);
createMD(title, destinationDirectory, true)
let formatedHtml = content
.replace(html_reg_objectHeader,"")
.replace(html_reg_objectSpanNew,"");
createTemplate(title, formatedHtml);
}
function handleGlobal(title, content){
createMD("API_Globals", map_dir_md["Global"], false);
createTemplate("API_Globals", content);
}
// Remove grav directory if exists to make sure old files aren't kept
if (fs.existsSync(dir_grav)){
console.log("dir_grav exists");
rimraf.sync(dir_grav);
}
// Create Grav directories in JSDOC output
dirArray.forEach(function(dir){
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
})
// Create baseMD files
baseMDDirectories.forEach( md => {
createMD(md, map_dir_md[md]);
})
// Read jsdoc output folder and process html files
let files = fs.readdirSync(dir_out);
files.forEach(function (file){
let curSource = path.join(dir_out, file);
if (path.extname(curSource) == ".html" && path.basename(curSource, '.html') !== "index") {
// Clean up the html source
let loadedHtml = prepareHtml(curSource);
// Extract the title, group name, and the main div
let splitTitle = loadedHtml("title").text().split(": ");
let groupName = splitTitle[1];
let htmlTitle = splitTitle.pop();
let mainDiv = loadedHtml("#main").html();
// Strip out undesired regex
let mainDivRegexed = mainDiv.replace(html_reg_static,"")
.replace(html_reg_title,"")
.replace(html_reg_htmlExt,"");
// Handle Unique Categories
switch(groupName){
case "Namespace":
handleNamespace(htmlTitle, mainDivRegexed);
break;
case "Class":
handleClass(htmlTitle, mainDivRegexed);
break;
case "Global":
handleGlobal(htmlTitle, mainDivRegexed);
break;
default:
console.log(`Case not handled for ${groupName}`);
}
}
})
// Create the base Templates after processing individual files
createTemplate("API-Reference","");
createTemplate("Globals","");
createTemplate("Namespaces","");
createTemplate("Objects","");
// Copy files to the Twig Directory
let templateFiles = fs.readdirSync(path.resolve(targetTemplateDirectory));
// Remove Existing API files
templateFiles.forEach(function(file){
let curSource = path.join(targetTemplateDirectory, file);
if(path.basename(file, '.html').indexOf("API") > -1){
fs.unlink(curSource);
}
})
copyFolderRecursiveSync(dir_template, targetTemplateDirectory);
// Copy files to the Md Directory
let baseMdRefDir = path.join(targetMDDirectory,"06.api-reference");
// Remove existing MD directory
if (fs.existsSync(baseMdRefDir)){
rimraf.sync(baseMdRefDir);
}
copyFolderRecursiveSync(dir_md, targetMDDirectory);

View file

@ -2,6 +2,7 @@
"name": "hifiJSDoc",
"dependencies": {
"cheerio": "^1.0.0-rc.2",
"dedent-js": "^1.0.1",
"htmlclean": "^3.0.8",
"jsdoc": "^3.5.5",
"pretty": "^2.0.0",

View file

@ -107,7 +107,7 @@ exports.handlers = {
// Append an Available In: table at the end of the namespace description.
if (rows.length > 0) {
var table = "<br><br><table><tr><th>Available in:</th><td>" + rows.join("</td><td>") + "</td></tr></table>";
e.doclet.description = e.doclet.description + table;
e.doclet.description = (e.doclet.description ? e.doclet.description : "") + table;
}
}
}