mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2334] Added status icons and version index based on metadata (#2987)
* [ADF-2334] Added status icons to index page * [ADF-2334] Improved status icons * [ADF-2334] Added version index page * [ADF-2334] Fixed bad anchors in version index
This commit is contained in:
committed by
Eugenio Romano
parent
c915a79342
commit
ad3dbd4d0b
@@ -3,8 +3,18 @@
|
||||
Below is an index of the documentation for ADF. The [User Guide](#user-guide)
|
||||
section discusses particular techniques in depth. The other sections are references for the ADF
|
||||
libraries. Click the name of an item to see its documentation or click the source link to see
|
||||
its main source file. Note that ADF is developed continuously, so the source files for some items
|
||||
may be listed here before their documentation is available.
|
||||
its main source file. Note that ADF is developed continuously, so the source files for some items may be listed here before their documentation is available.
|
||||
|
||||
See the [Version Index](versionIndex.md) for a list of components ordered by
|
||||
the ADF version where they were introduced.
|
||||
|
||||
Components are sometimes marked with an icon to show their status. No icon indicates
|
||||
that the component is complete and suitable for normal use. The other status levels are:
|
||||
|
||||
- **Deprecated**  - The component is still available
|
||||
but is now obsolete and will probably be removed in a future version of ADF.
|
||||
- **Experimental**  - The component is available for
|
||||
experimentation but not fully complete and tested for production code.
|
||||
|
||||
## Contents
|
||||
|
||||
@@ -22,7 +32,6 @@ may be listed here before their documentation is available.
|
||||
- [Angular Material Design](angular-material-design.md)
|
||||
- [Theming](theming.md)
|
||||
- [Typography](typography.md)
|
||||
- [Internationalization](internationalization.md)
|
||||
- [Walkthrough - adding indicators to highlight information about a node](metadata-indicators.md)
|
||||
|
||||
<!--guide end-->
|
||||
@@ -130,7 +139,7 @@ for more information about installing and using the source code.
|
||||
| [Page title service](page-title.service.md) | Sets the page title. | [Source](../lib/core/services/page-title.service.ts) |
|
||||
| [People content service](people-content.service.md) | Gets information about a Content Services user. | [Source](../lib/core/services/people-content.service.ts) |
|
||||
| [People process service](people-process.service.md) | Gets information about Process Services users. | [Source](../lib/core/services/people-process.service.ts) |
|
||||
| [Renditions service](renditions.service.md) | Manages prearranged conversions of content to different formats. | [Source](../lib/core/services/renditions.service.ts) |
|
||||
| [Renditions service](renditions.service.md)  | Manages prearranged conversions of content to different formats. | [Source](../lib/core/services/renditions.service.ts) |
|
||||
| [Search configuration service](search-configuration.service.md) | Provides fine control of parameters to a search. | [Source](../lib/core/services/search-configuration.service.ts) |
|
||||
| [Shared links api service](shared-links-api.service.md) | Finds shared links to Content Services items. | [Source](../lib/core/services/shared-links-api.service.ts) |
|
||||
| [Sites service](sites.service.md) | Accesses and manipulates sites from a Content Services repository. | [Source](../lib/core/services/sites.service.ts) |
|
||||
@@ -191,18 +200,19 @@ for more information about installing and using the source code.
|
||||
| [File uploading dialog component](file-uploading-dialog.component.md) | Shows a dialog listing all the files uploaded with the Upload Button or Drag Area components. | [Source](../lib/content-services/upload/components/file-uploading-dialog.component.ts) |
|
||||
| [Upload button component](upload-button.component.md) | Activates a file upload. | [Source](../lib/content-services/upload/components/upload-button.component.ts) |
|
||||
| [Upload drag area component](upload-drag-area.component.md) | Adds a drag and drop area to upload files to Alfresco. | [Source](../lib/content-services/upload/components/upload-drag-area.component.ts) |
|
||||
| [Version list component](version-list.component.md) | Displays the version history of a node in a [Version Manager component](version-manager.component.md) | [Source](../lib/content-services/version-manager/version-list.component.ts) |
|
||||
| [Version manager component](version-manager.component.md) | Displays the version history of a node with the ability to upload a new version. | [Source](../lib/content-services/version-manager/version-manager.component.ts) |
|
||||
| [Version list component](version-list.component.md)  | Displays the version history of a node in a [Version Manager component](version-manager.component.md) | [Source](../lib/content-services/version-manager/version-list.component.ts) |
|
||||
| [Version manager component](version-manager.component.md)  | Displays the version history of a node with the ability to upload a new version. | [Source](../lib/content-services/version-manager/version-manager.component.ts) |
|
||||
| [Webscript component](webscript.component.md) | Provides access to Webscript features. | [Source](../lib/content-services/webscript/webscript.component.ts) |
|
||||
| _Empty search result component_ | _Not currently documented_ | [Source](../lib/content-services/search/components/empty-search-result.component.ts) |
|
||||
|
||||
## Directives
|
||||
|
||||
| Name | Description | Source link |
|
||||
| ---- | ----------- | ----------- |
|
||||
| [Node download directive](node-download.directive.md) | Allows folders and/or files to be downloaded. Multiple nodes are packed as a '.ZIP' archive. | [Source](../lib/content-services/directives/node-download.directive.ts) |
|
||||
| [Folder create directive](folder-create.directive.md) | Allows folders to be created. | [Source](../lib/content-services/folder-directive/folder-create.directive.ts) |
|
||||
| [Folder edit directive](folder-edit.directive.md) | Allows folders to be edited. | [Source](../lib/content-services/folder-directive/folder-edit.directive.ts) |
|
||||
| [File draggable directive](file-draggable.directive.md) | Provide drag-and-drop features for an element such as a `div`. | [Source](../lib/content-services/upload/directives/file-draggable.directive.ts) |
|
||||
| [Node download directive](node-download.directive.md) | Downloads folders and files. Packs folders and/or multiple files into a .ZIP archive. | [Source](../lib/content-services/directives/node-download.directive.ts) |
|
||||
|
||||
## Models
|
||||
|
||||
@@ -221,6 +231,7 @@ for more information about installing and using the source code.
|
||||
| [Folder actions service](folder-actions.service.md) | Implements the folder menu actions for the Document List component. | [Source](../lib/content-services/document-list/services/folder-actions.service.ts) |
|
||||
| [Rating service](rating.service.md) | Manages ratings for items in Content Services. | [Source](../lib/content-services/social/services/rating.service.ts) |
|
||||
| [Tag service](tag.service.md) | Manages tags in Content Services. | [Source](../lib/content-services/tag/services/tag.service.ts) |
|
||||
| _Property groups translator service_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/services/property-groups-translator.service.ts) |
|
||||
|
||||
<!--content-services end-->
|
||||
|
||||
@@ -311,7 +322,7 @@ for more information about installing and using the source code.
|
||||
| [Analytics generator component](analytics-generator.component.md) | Generates and shows charts | [Source](../lib/insights/analytics-process/components/analytics-generator.component.ts) |
|
||||
| [Analytics report list component](analytics-report-list.component.md) | Shows a list of all available reports | [Source](../lib/insights/analytics-process/components/analytics-report-list.component.ts) |
|
||||
| [Analytics component](analytics.component.md) | Shows the charts related to the reportId passed as input | [Source](../lib/insights/analytics-process/components/analytics.component.ts) |
|
||||
| [Diagram component](diagram.component.md) | This component shows the diagram of a process. | [Source](../lib/insights/diagram/components/diagram.component.ts) |
|
||||
| [Diagram component](diagram.component.md) | Displays process diagrams. | [Source](../lib/insights/diagram/components/diagram.component.ts) |
|
||||
|
||||
<!--insights end-->
|
||||
|
||||
|
BIN
docs/docassets/images/DeprecatedIcon.png
Normal file
BIN
docs/docassets/images/DeprecatedIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 595 B |
BIN
docs/docassets/images/ExperimentalIcon.png
Normal file
BIN
docs/docassets/images/ExperimentalIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 642 B |
178
docs/versionIndex.md
Normal file
178
docs/versionIndex.md
Normal file
@@ -0,0 +1,178 @@
|
||||
# Version Index
|
||||
|
||||
This file contains a list of components grouped according to the
|
||||
ADF version in which they were introduced. See the
|
||||
[main index page](README.md) for a list organized by ADF libraries.
|
||||
|
||||
<!--history start-->
|
||||
|
||||
## Versions
|
||||
|
||||
- [v2.2.0](#v220)
|
||||
- [v2.1.0](#v210)
|
||||
- [v2.0.0](#v200)
|
||||
|
||||
## v2.2.0
|
||||
|
||||
- [Node download directive](node-download.directive.md)
|
||||
|
||||
## v2.1.0
|
||||
|
||||
- [Content metadata component](content-metadata.component.md)
|
||||
- [Content node dialog service](content-node-dialog.service.md)
|
||||
- [Content node selector panel component](content-node-selector-panel.component.md)
|
||||
- [Search configuration service](search-configuration.service.md)
|
||||
- [Sidebar action menu component](sidebar-action-menu.component.md)
|
||||
|
||||
## v2.0.0
|
||||
|
||||
- [Accordion group component](accordion-group.component.md)
|
||||
- [Accordion component](accordion.component.md)
|
||||
- [Activiti alfresco service](activiti-alfresco.service.md)
|
||||
- [Alfresco api service](alfresco-api.service.md)
|
||||
- [Alfresco content service](alfresco-content.service.md)
|
||||
- [Analytics generator component](analytics-generator.component.md)
|
||||
- [Analytics report list component](analytics-report-list.component.md)
|
||||
- [Analytics component](analytics.component.md)
|
||||
- [App config service](app-config.service.md)
|
||||
- [Apps list component](apps-list.component.md)
|
||||
- [Apps process service](apps-process.service.md)
|
||||
- [Auth guard bpm service](auth-guard-bpm.service.md)
|
||||
- [Auth guard ecm service](auth-guard-ecm.service.md)
|
||||
- [Auth guard service](auth-guard.service.md)
|
||||
- [Authentication service](authentication.service.md)
|
||||
- [Bpm user model](bpm-user.model.md)
|
||||
- [Bpm user service](bpm-user.service.md)
|
||||
- [Breadcrumb component](breadcrumb.component.md)
|
||||
- [Card view update service](card-view-update.service.md)
|
||||
- [Card view component](card-view.component.md)
|
||||
- [Checklist component](checklist.component.md)
|
||||
- [Comment list component](comment-list.component.md)
|
||||
- [Comment process model](comment-process.model.md)
|
||||
- [Comment process service](comment-process.service.md)
|
||||
- [Comments component](comments.component.md)
|
||||
- [Content action component](content-action.component.md)
|
||||
- [Content node selector component](content-node-selector.component.md)
|
||||
- [Content service](content.service.md)
|
||||
- [Content widget](content.widget.md)
|
||||
- [Context menu directive](context-menu.directive.md)
|
||||
- [Cookie service](cookie.service.md)
|
||||
- [Create process attachment component](create-process-attachment.component.md)
|
||||
- [Create task attachment component](create-task-attachment.component.md)
|
||||
- [Data column component](data-column.component.md)
|
||||
- [Datatable component](datatable.component.md)
|
||||
- [Deleted nodes api service](deleted-nodes-api.service.md)
|
||||
- [Diagram component](diagram.component.md)
|
||||
- [Discovery api service](discovery-api.service.md)
|
||||
- [Document actions service](document-actions.service.md)
|
||||
- [Document library model](document-library.model.md)
|
||||
- [Document list component](document-list.component.md)
|
||||
- [Document list service](document-list.service.md)
|
||||
- [Dropdown breadcrumb component](dropdown-breadcrumb.component.md)
|
||||
- [Ecm user model](ecm-user.model.md)
|
||||
- [Ecm user service](ecm-user.service.md)
|
||||
- [Favorites api service](favorites-api.service.md)
|
||||
- [File draggable directive](file-draggable.directive.md)
|
||||
- [File size pipe](file-size.pipe.md)
|
||||
- [File uploading dialog component](file-uploading-dialog.component.md)
|
||||
- [Filter model](filter.model.md)
|
||||
- [Folder actions service](folder-actions.service.md)
|
||||
- [Folder create directive](folder-create.directive.md)
|
||||
- [Folder edit directive](folder-edit.directive.md)
|
||||
- [Form field component](form-field.component.md)
|
||||
- [Form field model](form-field.model.md)
|
||||
- [Form list component](form-list.component.md)
|
||||
- [Form rendering service](form-rendering.service.md)
|
||||
- [Form component](form.component.md)
|
||||
- [Form service](form.service.md)
|
||||
- [Highlight transform service](highlight-transform.service.md)
|
||||
- [Highlight directive](highlight.directive.md)
|
||||
- [Host settings component](host-settings.component.md)
|
||||
- [Infinite pagination component](infinite-pagination.component.md)
|
||||
- [Info drawer layout component](info-drawer-layout.component.md)
|
||||
- [Info drawer component](info-drawer.component.md)
|
||||
- [Language menu component](language-menu.component.md)
|
||||
- [Like component](like.component.md)
|
||||
- [Log service](log.service.md)
|
||||
- [Login component](login.component.md)
|
||||
- [Logout directive](logout.directive.md)
|
||||
- [Mime type icon pipe](mime-type-icon.pipe.md)
|
||||
- [Node delete directive](node-delete.directive.md)
|
||||
- [Node favorite directive](node-favorite.directive.md)
|
||||
- [Node name tooltip pipe](node-name-tooltip.pipe.md)
|
||||
- [Node permission directive](node-permission.directive.md)
|
||||
- [Node restore directive](node-restore.directive.md)
|
||||
- [Node service](node.service.md)
|
||||
- [Nodes api service](nodes-api.service.md)
|
||||
- [Notification service](notification.service.md)
|
||||
- [Page title service](page-title.service.md)
|
||||
- [Pagination component](pagination.component.md)
|
||||
- [People content service](people-content.service.md)
|
||||
- [People list component](people-list.component.md)
|
||||
- [People process service](people-process.service.md)
|
||||
- [People search component](people-search.component.md)
|
||||
- [People component](people.component.md)
|
||||
- [Permissions style model](permissions-style.model.md)
|
||||
- [Process attachment list component](process-attachment-list.component.md)
|
||||
- [Process audit directive](process-audit.directive.md)
|
||||
- [Process comments component](process-comments.component.md)
|
||||
- [Process content service](process-content.service.md)
|
||||
- [Process filter service](process-filter.service.md)
|
||||
- [Process filters component](process-filters.component.md)
|
||||
- [Process instance details component](process-instance-details.component.md)
|
||||
- [Process instance header component](process-instance-header.component.md)
|
||||
- [Process instance tasks component](process-instance-tasks.component.md)
|
||||
- [Process list component](process-list.component.md)
|
||||
- [Process service](process.service.md)
|
||||
- [Product version model](product-version.model.md)
|
||||
- [Rating component](rating.component.md)
|
||||
- [Rating service](rating.service.md)
|
||||
- [Renditions service](renditions.service.md)
|
||||
- [Search api service](search-api.service.md)
|
||||
- [Search control component](search-control.component.md)
|
||||
- [Search component](search.component.md)
|
||||
- [Select apps dialog component](select-apps-dialog.component.md)
|
||||
- [Shared links api service](shared-links-api.service.md)
|
||||
- [Site model](site.model.md)
|
||||
- [Sites dropdown component](sites-dropdown.component.md)
|
||||
- [Sites service](sites.service.md)
|
||||
- [Start form component](start-form.component.md)
|
||||
- [Start process component](start-process.component.md)
|
||||
- [Start task component](start-task.component.md)
|
||||
- [Storage service](storage.service.md)
|
||||
- [Tag actions component](tag-actions.component.md)
|
||||
- [Tag list component](tag-list.component.md)
|
||||
- [Tag node list component](tag-node-list.component.md)
|
||||
- [Tag service](tag.service.md)
|
||||
- [Task attachment list component](task-attachment-list.component.md)
|
||||
- [Task audit directive](task-audit.directive.md)
|
||||
- [Task details component](task-details.component.md)
|
||||
- [Task details model](task-details.model.md)
|
||||
- [Task filter service](task-filter.service.md)
|
||||
- [Task filters component](task-filters.component.md)
|
||||
- [Task header component](task-header.component.md)
|
||||
- [Task list component](task-list.component.md)
|
||||
- [Tasklist service](tasklist.service.md)
|
||||
- [Text highlight pipe](text-highlight.pipe.md)
|
||||
- [Text mask component](text-mask.component.md)
|
||||
- [Thumbnail service](thumbnail.service.md)
|
||||
- [Time ago pipe](time-ago.pipe.md)
|
||||
- [Toolbar divider component](toolbar-divider.component.md)
|
||||
- [Toolbar title component](toolbar-title.component.md)
|
||||
- [Toolbar component](toolbar.component.md)
|
||||
- [Translation service](translation.service.md)
|
||||
- [Upload button component](upload-button.component.md)
|
||||
- [Upload drag area component](upload-drag-area.component.md)
|
||||
- [Upload directive](upload.directive.md)
|
||||
- [Upload service](upload.service.md)
|
||||
- [User info component](user-info.component.md)
|
||||
- [User initial pipe](user-initial.pipe.md)
|
||||
- [User preferences service](user-preferences.service.md)
|
||||
- [User process model](user-process.model.md)
|
||||
- [Version list component](version-list.component.md)
|
||||
- [Version manager component](version-manager.component.md)
|
||||
- [Viewer component](viewer.component.md)
|
||||
- [Webscript component](webscript.component.md)
|
||||
- [Widget component](widget.component.md)
|
||||
|
||||
<!--history end-->
|
@@ -5,12 +5,8 @@ var program = require("commander");
|
||||
var remark = require("remark");
|
||||
var parse = require("remark-parse");
|
||||
var stringify = require("remark-stringify");
|
||||
var frontMatter = require("remark-frontmatter");
|
||||
|
||||
/*
|
||||
var managetoc = require("./managetoc");
|
||||
var sa = require("./seealso");
|
||||
var index = require("./index");
|
||||
*/
|
||||
|
||||
// "Aggregate" data collected over the whole file set.
|
||||
var aggData = {};
|
||||
@@ -21,11 +17,6 @@ var defaultFolder = path.resolve("..", "docs");
|
||||
|
||||
|
||||
function initPhase(aggData) {
|
||||
/*
|
||||
toolModules.seealso.initPhase(aggData);
|
||||
toolModules.index.initPhase(aggData);
|
||||
*/
|
||||
|
||||
toolList.forEach(toolName => {
|
||||
toolModules[toolName].initPhase(aggData);
|
||||
});
|
||||
@@ -37,16 +28,11 @@ function readPhase(srcFolder, filenames, aggData) {
|
||||
var pathname = path.resolve(srcFolder, filenames[i]);
|
||||
|
||||
var src = fs.readFileSync(pathname);
|
||||
var tree = remark().parse(src)
|
||||
var tree = remark().use(frontMatter, ["yaml"]).parse(src);
|
||||
|
||||
toolList.forEach(toolName => {
|
||||
toolModules[toolName].readPhase(tree, pathname, aggData);
|
||||
});
|
||||
|
||||
/*
|
||||
toolModules.seealso.readPhase(tree, pathname, aggData);
|
||||
toolModules.index.readPhase(tree, pathname, aggData);
|
||||
*/
|
||||
}
|
||||
|
||||
//console.log(JSON.stringify(aggData.mdFileData));
|
||||
@@ -57,11 +43,6 @@ function aggPhase(aggData) {
|
||||
toolList.forEach(toolName => {
|
||||
toolModules[toolName].aggPhase(aggData);
|
||||
});
|
||||
|
||||
/*
|
||||
toolModules.seealso.aggPhase(aggData);
|
||||
toolModules.index.aggPhase(aggData);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -119,15 +100,7 @@ if (program.args.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
var sourcePath;
|
||||
|
||||
|
||||
if (program.args.length > 0)
|
||||
sourcePath = path.resolve(program.args[0]);
|
||||
else
|
||||
sourcePath = defaultFolder;
|
||||
*/
|
||||
var sourcePath = path.resolve(program.args[0]);
|
||||
var sourceInfo = fs.statSync(sourcePath);
|
||||
|
||||
|
@@ -4,6 +4,7 @@ var path = require("path");
|
||||
var remark = require("remark");
|
||||
var stringify = require("remark-stringify");
|
||||
var zone = require("mdast-zone");
|
||||
var yaml = require("js-yaml");
|
||||
|
||||
var unist = require("../unistHelpers");
|
||||
var ngHelpers = require("../ngHelpers");
|
||||
@@ -29,11 +30,15 @@ var maxBriefDescLength = 180;
|
||||
|
||||
var adfLibNames = ["core", "content-services", "insights", "process-services"];
|
||||
|
||||
var deprecatedIconURL = "docassets/images/DeprecatedIcon.png";
|
||||
var experimentalIconURL = "docassets/images/ExperimentalIcon.png";
|
||||
|
||||
|
||||
function initPhase(aggData) {
|
||||
aggData.stoplist = makeStoplist(undocStoplistFileName);
|
||||
aggData.srcData = {};
|
||||
aggData.mdFileDesc = [];
|
||||
aggData.mdFileStatus = [];
|
||||
|
||||
searchLibraryRecursive(aggData.srcData, path.resolve(rootFolder));
|
||||
|
||||
@@ -49,8 +54,12 @@ function readPhase(tree, pathname, aggData) {
|
||||
var s;
|
||||
var briefDesc;
|
||||
|
||||
for (
|
||||
if (tree.children[0].type == "yaml")
|
||||
s = 1;
|
||||
else
|
||||
s = 0;
|
||||
|
||||
for (;
|
||||
(s < tree.children.length) && !unist.isParagraph(tree.children[s]);
|
||||
s++
|
||||
);
|
||||
@@ -60,6 +69,17 @@ function readPhase(tree, pathname, aggData) {
|
||||
}
|
||||
|
||||
aggData.mdFileDesc[itemName] = briefDesc;
|
||||
|
||||
if (tree.children[0].type == "yaml") {
|
||||
var metadata = yaml.load(tree.children[0].value);
|
||||
var status = metadata["Status"];
|
||||
|
||||
if (status) {
|
||||
var compName = path.basename(pathname, ".md");
|
||||
aggData.mdFileStatus[compName] = status;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function aggPhase(aggData) {
|
||||
@@ -165,12 +185,18 @@ function prepareIndexSections(aggData) {
|
||||
|
||||
var displayName = ngHelpers.ngNameToDisplayName(itemName);
|
||||
|
||||
var status = "";
|
||||
|
||||
if (aggData.mdFileStatus[itemName])
|
||||
status = aggData.mdFileStatus[itemName];
|
||||
|
||||
if (briefDesc) {
|
||||
sections[libName][srcData.type].documented.push({
|
||||
"displayName": displayName,
|
||||
"mdName": itemName + ".md",
|
||||
"srcPath": srcData.path,
|
||||
"briefDesc": briefDesc
|
||||
"briefDesc": briefDesc,
|
||||
"status": status
|
||||
});
|
||||
} else if (!rejectItemViaStoplist(aggData.stoplist, itemName)) {
|
||||
sections[libName][srcData.type].undocumented.push({
|
||||
@@ -283,8 +309,20 @@ function makeMDDocumentedTableRow(docItem) {
|
||||
var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath);
|
||||
var desc = docItem.briefDesc;
|
||||
|
||||
var linkCellItems = [mdFileLink];
|
||||
|
||||
if (docItem.status) {
|
||||
if (docItem.status === "Deprecated") {
|
||||
linkCellItems.push(unist.makeText(" "));
|
||||
linkCellItems.push(unist.makeImage(deprecatedIconURL, "Deprecated"));
|
||||
} else if (docItem.status === "Experimental") {
|
||||
linkCellItems.push(unist.makeText(" "));
|
||||
linkCellItems.push(unist.makeImage(experimentalIconURL, "Experimental"));
|
||||
}
|
||||
}
|
||||
|
||||
return unist.makeTableRow([
|
||||
unist.makeTableCell([mdFileLink]),
|
||||
unist.makeTableCell(linkCellItems),
|
||||
unist.makeTableCell([desc]),
|
||||
unist.makeTableCell([srcFileLink])
|
||||
]);
|
||||
|
121
lib/config/DocProcessor/tools/versionIndex.js
Normal file
121
lib/config/DocProcessor/tools/versionIndex.js
Normal file
@@ -0,0 +1,121 @@
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var yaml = require("js-yaml");
|
||||
|
||||
var remark = require("remark");
|
||||
var stringify = require("remark-stringify");
|
||||
var zone = require("mdast-zone");
|
||||
|
||||
var unist = require("../unistHelpers");
|
||||
var ngHelpers = require("../ngHelpers");
|
||||
|
||||
|
||||
module.exports = {
|
||||
"initPhase": initPhase,
|
||||
"readPhase": readPhase,
|
||||
"aggPhase": aggPhase,
|
||||
"updatePhase": updatePhase
|
||||
}
|
||||
|
||||
var angFilenameRegex = /([a-zA-Z0-9\-]+)\.((component)|(directive)|(model)|(pipe)|(service)|(widget))\.ts/;
|
||||
|
||||
var docsFolderPath = path.resolve("..", "docs");
|
||||
var histFilePath = path.resolve(docsFolderPath, "versionIndex.md");
|
||||
|
||||
var histSectionName = "history";
|
||||
var initialVersion = "v2.0.0";
|
||||
|
||||
function initPhase(aggData) {
|
||||
aggData.versions = { "v2.0.0":[] };
|
||||
}
|
||||
|
||||
|
||||
function readPhase(tree, pathname, aggData) {
|
||||
var compName = path.basename(pathname, ".md");
|
||||
var angNameRegex = /([a-zA-Z0-9\-]+)\.((component)|(directive)|(model)|(pipe)|(service)|(widget))/;
|
||||
|
||||
if (!compName.match(angNameRegex))
|
||||
return;
|
||||
|
||||
if (compName.match(/boilerplate/))
|
||||
return;
|
||||
|
||||
if (tree.children[0].type == "yaml") {
|
||||
var metadata = yaml.load(tree.children[0].value);
|
||||
var version = metadata["Added"];
|
||||
|
||||
if (version) {
|
||||
if (aggData.versions[version]) {
|
||||
aggData.versions[version].push(compName);
|
||||
} else {
|
||||
aggData.versions[version] = [compName];
|
||||
}
|
||||
} else {
|
||||
aggData.versions[initialVersion].push(compName);
|
||||
}
|
||||
} else {
|
||||
aggData.versions[initialVersion].push(compName);
|
||||
}
|
||||
}
|
||||
|
||||
function aggPhase(aggData) {
|
||||
var histFileText = fs.readFileSync(histFilePath, "utf8");
|
||||
var histFileTree = remark().parse(histFileText);
|
||||
|
||||
var keys = Object.keys(aggData.versions);
|
||||
keys.sort((a, b) => {
|
||||
if (a > b)
|
||||
return -1;
|
||||
else if (b > a)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
});
|
||||
|
||||
var sections = [unist.makeHeading(unist.makeText("Versions"), 2)];
|
||||
|
||||
var vListItems = [];
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var keyAnchor = keys[i].replace(/\./g, "");
|
||||
vListItems.push(unist.makeListItem(unist.makeLink(unist.makeText(keys[i]), `#${keyAnchor}`)));
|
||||
}
|
||||
|
||||
sections.push(unist.makeListUnordered(vListItems));
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var version = keys[i];
|
||||
var versionItems = aggData.versions[version];
|
||||
versionItems.sort();
|
||||
|
||||
var versListItems = [];
|
||||
|
||||
for (var v = 0; v < versionItems.length; v++) {
|
||||
var displayName = ngHelpers.ngNameToDisplayName(versionItems[v]);
|
||||
var pageLink = versionItems[v] + ".md";
|
||||
|
||||
versListItems.push(
|
||||
unist.makeListItem(
|
||||
unist.makeLink(unist.makeText(displayName), pageLink)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
sections.push(unist.makeHeading(unist.makeText(version), 2));
|
||||
sections.push(unist.makeListUnordered(versListItems));
|
||||
}
|
||||
|
||||
zone(histFileTree, histSectionName, (startComment, oldSection, endComment) => {
|
||||
sections.unshift(startComment);
|
||||
sections.push(endComment);
|
||||
return sections;
|
||||
});
|
||||
|
||||
//console.log(JSON.stringify(histFileTree));
|
||||
fs.writeFileSync(histFilePath, remark().stringify(histFileTree));
|
||||
}
|
||||
|
||||
|
||||
function updatePhase(tree, pathname, aggData) {
|
||||
return false;
|
||||
}
|
@@ -110,6 +110,14 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
makeImage: function (url, alt) {
|
||||
return {
|
||||
"type": "image",
|
||||
"url": url,
|
||||
"alt": alt
|
||||
}
|
||||
},
|
||||
|
||||
isHeading: function (node) {
|
||||
return node.type === "heading";
|
||||
},
|
||||
|
Reference in New Issue
Block a user