From da9d0e0ec2b5d1209d7672fcc4cb48bd3a4d3809 Mon Sep 17 00:00:00 2001 From: Andy Stark <30621568+therealandeeee@users.noreply.github.com> Date: Tue, 9 Jan 2018 10:36:24 +0000 Subject: [PATCH] [ADF-2127] Started introducing new doc tools (#2809) --- docs/README.md | 417 +++++++++++--------- docs/activiti-alfresco.service.md | 3 +- docs/folder-create.directive.md | 13 +- docs/folder-edit.directive.md | 13 +- docs/form-field.model.md | 3 +- docs/host-settings.component.md | 3 +- docs/like.component.md | 2 + docs/node-restore.directive.md | 2 + docs/node.service.md | 3 +- docs/process-content.service.md | 5 +- docs/rating.component.md | 2 + docs/start-process.component.md | 6 +- docs/tag-actions.component.md | 2 + docs/tag-list.component.md | 2 + docs/tag-node-list.component.md | 2 + docs/upload-button.component.md | 2 + docs/user-info.component.md | 2 + docs/version-list.component.md | 3 +- lib/config/DocProcessor/docProcessor.js | 175 ++++++++ lib/config/DocProcessor/doctool.config.json | 5 + lib/config/DocProcessor/ngHelpers.js | 19 + lib/config/DocProcessor/tools/index.js | 362 +++++++++++++++++ lib/config/DocProcessor/tools/seealso.js | 175 ++++++++ lib/config/DocProcessor/tools/toc.js | 82 ++++ lib/config/DocProcessor/tools/tscProps.js | 181 +++++++++ lib/config/DocProcessor/tools/tscProps.ts | 237 +++++++++++ lib/config/DocProcessor/unistHelpers.js | 101 +++++ 27 files changed, 1599 insertions(+), 223 deletions(-) create mode 100644 lib/config/DocProcessor/docProcessor.js create mode 100644 lib/config/DocProcessor/doctool.config.json create mode 100644 lib/config/DocProcessor/ngHelpers.js create mode 100644 lib/config/DocProcessor/tools/index.js create mode 100644 lib/config/DocProcessor/tools/seealso.js create mode 100644 lib/config/DocProcessor/tools/toc.js create mode 100644 lib/config/DocProcessor/tools/tscProps.js create mode 100644 lib/config/DocProcessor/tools/tscProps.ts create mode 100644 lib/config/DocProcessor/unistHelpers.js diff --git a/docs/README.md b/docs/README.md index 77cc1d8898..3a006420b3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,27 +2,29 @@ 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. Items marked with an asterisk (*) do not currently have documentation - the link leads +libraries. Items marked with an asterisk (\*) do not currently have documentation - the link leads to the appropriate source file. ## Contents -- [User Guide](#user-guide) -- [ADF Core](#adf-core) -- [ADF Content Services](#adf-content-services) -- [ADF Process Services](#adf-process-services) -- [ADF Insights](#adf-insights) +- [User Guide](#user-guide) +- [ADF Core](#adf-core) +- [ADF Content Services](#adf-content-services) +- [ADF Process Services](#adf-process-services) +- [ADF Insights](#adf-insights) ## User guide - -- [Form Extensibility and Customisation](extensibility.md) -- [Angular Material Design](angular-material-design.md) -- [Theming](theming.md) -- [Typography](typography.md) -- [Walkthrough - adding indicators to highlight information about a node](metadata-indicators.md) + + +- [Form Extensibility and Customisation](extensibility.md) +- [Angular Material Design](angular-material-design.md) +- [Theming](theming.md) +- [Typography](typography.md) +- [Walkthrough - adding indicators to highlight information about a node](metadata-indicators.md) + + - [(Back to Contents)](#contents) ## ADF Core @@ -31,111 +33,125 @@ Contains a variety of components used throughout ADF. See the library's [README file](../lib/core/README.md) for more information about installing and using the source code. - -### Components + -- [Card view component](card-view.component.md) -- [Accordion group component](accordion-group.component.md) -- [Accordion component](accordion.component.md) -- [Data column component](data-column.component.md) -- [Datatable component](datatable.component.md) -- [Form field component](form-field.component.md) -- [Form list component](form-list.component.md) -- [Form component](form.component.md) -- [Start form component](start-form.component.md) -- [Text mask component](text-mask.component.md) -- [Widget component](widget.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) -- [Login component](login.component.md) -- [Infinite pagination component](infinite-pagination.component.md) -- [Pagination component](pagination.component.md) -- [Host settings component](host-settings.component.md) -- [Toolbar divider component](toolbar-divider.component.md) -- [Toolbar title component](toolbar-title.component.md) -- [Toolbar component](toolbar.component.md) -- [User info component](user-info.component.md) -- [Viewer component](viewer.component.md) +## Components -### Directives +| Name | Description | Source link | +| ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| [Card view component](card-view.component.md) | Displays a configurable property list renderer. | [Source](../lib/core/card-view/card-view.component.ts) | +| [Accordion group component](accordion-group.component.md) | Adds a collapsible panel to an [accordion menu](accordion.component.md). | [Source](../lib/core/collapsable/accordion-group.component.ts) | +| [Accordion component](accordion.component.md) | Creates a collapsible accordion menu. | [Source](../lib/core/collapsable/accordion.component.ts) | +| [Data column component](data-column.component.md) | Defines column properties for DataTable, Tasklist, Document List and other components. | [Source](../lib/core/data-column/data-column.component.ts) | +| [Datatable component](datatable.component.md) | Displays data as a table with customizable columns and presentation. | [Source](../lib/core/datatable/components/datatable/datatable.component.ts) | +| [Form field component](form-field.component.md) | A form field in an APS form. | [Source](../lib/core/form/components/form-field/form-field.component.ts) | +| [Form list component](form-list.component.md) | The component shows the activiti forms as a list. | [Source](../lib/core/form/components/form-list.component.ts) | +| [Form component](form.component.md) | The component shows a Form from Activiti (see it live: [Form Quickstart](https://embed.plnkr.co/YSLXTqb3DtMhVJSqXKkE/)) | [Source](../lib/core/form/components/form.component.ts) | +| [Start form component](start-form.component.md) | Displays the Start Form for a process. | [Source](../lib/core/form/components/start-form.component.ts) | +| [Text mask component](text-mask.component.md) | Implements text field input masks. | [Source](../lib/core/form/components/widgets/text/text-mask.component.ts) | +| [Info drawer layout component](info-drawer-layout.component.md) | Displays a sidebar-style information panel. | [Source](../lib/core/info-drawer/info-drawer-layout.component.ts) | +| [Info drawer component](info-drawer.component.md) | Displays a sidebar-style information panel with tabs. | [Source](../lib/core/info-drawer/info-drawer.component.ts) | +| [Language menu component](language-menu.component.md) | Displays all the languages that are present in the "app.config.json" or the default one (EN). | [Source](../lib/core/language-menu/language-menu.component.ts) | +| [Login component](login.component.md) | Authenticates to Alfresco Content Services and Alfresco Process Services. | [Source](../lib/core/login/components/login.component.ts) | +| [Infinite pagination component](infinite-pagination.component.md) | Adds "infinite" pagination to the component it is used with. | [Source](../lib/core/pagination/infinite-pagination.component.ts) | +| [Pagination component](pagination.component.md) | Adds pagination to the component it is used with. | [Source](../lib/core/pagination/pagination.component.ts) | +| [Host settings component](host-settings.component.md) | Validates the URLs for ACS and APS and saves them in the user's local storage | [Source](../lib/core/settings/host-settings.component.ts) | +| [Toolbar divider component](toolbar-divider.component.md) | Divides groups of elements in a Toolbar with a visual separator. | [Source](../lib/core/toolbar/toolbar-divider.component.ts) | +| [Toolbar title component](toolbar-title.component.md) | Supplies custom HTML to be included in a Toolbar component title. | [Source](../lib/core/toolbar/toolbar-title.component.ts) | +| [Toolbar component](toolbar.component.md) | Simple container for headers, titles, actions and breadcrumbs. | [Source](../lib/core/toolbar/toolbar.component.ts) | +| [User info component](user-info.component.md) | Shows user information. | [Source](../lib/core/userinfo/components/user-info.component.ts) | +| [Viewer component](viewer.component.md) | See it live: [Viewer Quickstart](https://embed.plnkr.co/iTuG1lFIXfsP95l6bDW6/) | [Source](../lib/core/viewer/components/viewer.component.ts) | -- [Context menu directive](context-menu.directive.md) -- [Highlight directive](highlight.directive.md) -- [Logout directive](logout.directive.md) -- [Node delete directive](node-delete.directive.md) -- [Node favorite directive](node-favorite.directive.md) -- [Node permission directive](node-permission.directive.md) -- [Node restore directive](node-restore.directive.md) -- [Upload directive](upload.directive.md) +## Directives -### Models +| Name | Description | Source link | +| --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | +| [Context menu directive](context-menu.directive.md) | See **Demo Shell** or **DocumentList** implementation for more details and use cases. | [Source](../lib/core/context-menu/context-menu.directive.ts) | +| [Highlight directive](highlight.directive.md) | Adds highlighting to selected sections of an HTML element's content. | [Source](../lib/core/directives/highlight.directive.ts) | +| [Logout directive](logout.directive.md) | Logs the user out when the decorated element is clicked. | [Source](../lib/core/directives/logout.directive.ts) | +| [Node delete directive](node-delete.directive.md) | Deletes multiple files and folders. | [Source](../lib/core/directives/node-delete.directive.ts) | +| [Node favorite directive](node-favorite.directive.md) | Selectively toggles nodes as favorite | [Source](../lib/core/directives/node-favorite.directive.ts) | +| [Node permission directive](node-permission.directive.md) | Selectively disables an HTML element or Angular component | [Source](../lib/core/directives/node-permission.directive.ts) | +| [Node restore directive](node-restore.directive.md) | Restores deleted nodes to their original location. | [Source](../lib/core/directives/node-restore.directive.ts) | +| [Upload directive](upload.directive.md) | Allows your components or common HTML elements reacting on File drag and drop in order to upload content. | [Source](../lib/core/directives/upload.directive.ts) | -- [Form field model](form-field.model.md) -- [Comment process model](comment-process.model.md) -- [Product version model](product-version.model.md) -- [User process model](user-process.model.md) -- [Bpm user model](bpm-user.model.md) -- [Ecm user model](ecm-user.model.md) +## Models -### Pipes +| Name | Description | Source link | +| ------------------------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| [Form field model](form-field.model.md) | Contains the value and metadata for a field of an [ADF Form](form.component.md). | [Source](../lib/core/form/components/widgets/core/form-field.model.ts) | +| [Comment process model](comment-process.model.md) | Represents a comment added to a Process Services task or process instance. | [Source](../lib/core/models/comment-process.model.ts) | +| [Product version model](product-version.model.md) | Contains version and license information classes for Alfresco products. | [Source](../lib/core/models/product-version.model.ts) | +| [User process model](user-process.model.md) | Represents a Process Services user. | [Source](../lib/core/models/user-process.model.ts) | +| [Bpm user model](bpm-user.model.md) | Contains information about a Process Services user. | [Source](../lib/core/userinfo/models/bpm-user.model.ts) | +| [Ecm user model](ecm-user.model.md) | Contains information about a Content Services user. | [Source](../lib/core/userinfo/models/ecm-user.model.ts) | -- [File size pipe](file-size.pipe.md) -- [Mime type icon pipe](mime-type-icon.pipe.md) -- [Node name tooltip pipe](node-name-tooltip.pipe.md) -- [Text highlight pipe](text-highlight.pipe.md) -- [Time ago pipe](time-ago.pipe.md) -- [User initial pipe](user-initial.pipe.md) +## Pipes -### Services +| Name | Description | Source link | +| --------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------- | +| [File size pipe](file-size.pipe.md) | Converts a number of bytes to the equivalent in KB, MB, etc. | [Source](../lib/core/pipes/file-size.pipe.ts) | +| [Mime type icon pipe](mime-type-icon.pipe.md) | Retrieves an icon to represent a MIME type. | [Source](../lib/core/pipes/mime-type-icon.pipe.ts) | +| [Node name tooltip pipe](node-name-tooltip.pipe.md) | Formats the tooltip of the underlying Node based on the following rules: | [Source](../lib/core/pipes/node-name-tooltip.pipe.ts) | +| [Text highlight pipe](text-highlight.pipe.md) | Adds highlighting to words or sections of text that match a search string. | [Source](../lib/core/pipes/text-highlight.pipe.ts) | +| [Time ago pipe](time-ago.pipe.md) | Converts a recent past date into a number of days ago. | [Source](../lib/core/pipes/time-ago.pipe.ts) | +| [User initial pipe](user-initial.pipe.md) | Takes the name fields of a UserProcessModel object and extracts and formats the initials. | [Source](../lib/core/pipes/user-initial.pipe.ts) | -- [App config service](app-config.service.md) -- [Activiti alfresco service](activiti-alfresco.service.md) -- [Form rendering service](form-rendering.service.md) -- [Form service](form.service.md) -- [Node service](node.service.md) -- [Process content service](process-content.service.md) -- [Alfresco api service](alfresco-api.service.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) -- [Card view update service](card-view-update.service.md) -- [Comment process service](comment-process.service.md) -- [Content service](content.service.md) -- [Cookie service](cookie.service.md) -- [Deleted nodes api service](deleted-nodes-api.service.md) -- [Discovery api service](discovery-api.service.md) -- [Favorites api service](favorites-api.service.md) -- [Highlight transform service](highlight-transform.service.md) -- [Log service](log.service.md) -- [Nodes api service](nodes-api.service.md) -- [Notification service](notification.service.md) -- [Page title service](page-title.service.md) -- [People content service](people-content.service.md) -- [People process service](people-process.service.md) -- [Renditions service](renditions.service.md) -- [Shared links api service](shared-links-api.service.md) -- [Storage service](storage.service.md) -- [Thumbnail service](thumbnail.service.md) -- [Translation service](translation.service.md) -- [Upload service](upload.service.md) -- [User preferences service](user-preferences.service.md) -- [Bpm user service](bpm-user.service.md) -- [Ecm user service](ecm-user.service.md) -- [*Sites service](../lib/core/services/sites.service.ts) +## Services -### Widgets +| Name | Description | Source link | +| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | +| [Activiti alfresco service](activiti-alfresco.service.md) | Gets Alfresco Repository folder content based on a Repository account configured in Alfresco Process Services (APS). | [Source](../lib/core/form/services/activiti-alfresco.service.ts) | +| [Form rendering service](form-rendering.service.md) | Maps an APS form field type string onto the corresponding form widget component type. | [Source](../lib/core/form/services/form-rendering.service.ts) | +| [Form service](form.service.md) | Implements Process Services form methods | [Source](../lib/core/form/services/form.service.ts) | +| [Node service](node.service.md) | Gets Alfresco Repository node metadata and creates nodes with metadata. | [Source](../lib/core/form/services/node.service.ts) | +| [Process content service](process-content.service.md) | Manipulates content related to a Process Instance or Task Instance in APS. | [Source](../lib/core/form/services/process-content.service.ts) | +| [Alfresco api service](alfresco-api.service.md) | Provides access to initialized **AlfrescoJSApi** instance. | [Source](../lib/core/services/alfresco-api.service.ts) | +| [Apps process service](apps-process.service.md) | Gets details of the Process Services apps that are deployed for the user. | [Source](../lib/core/services/apps-process.service.ts) | +| [Auth guard bpm service](auth-guard-bpm.service.md) | Adds authentication with Process Services to a route within the app. | [Source](../lib/core/services/auth-guard-bpm.service.ts) | +| [Auth guard ecm service](auth-guard-ecm.service.md) | Adds authentication with Content Services to a route within the app. | [Source](../lib/core/services/auth-guard-ecm.service.ts) | +| [Auth guard service](auth-guard.service.md) | Adds authentication to a route within the app. | [Source](../lib/core/services/auth-guard.service.ts) | +| [Authentication service](authentication.service.md) | Provides authentication for use with the Login component. | [Source](../lib/core/services/authentication.service.ts) | +| [Card view update service](card-view-update.service.md) | Reports edits and clicks within fields of a [Card View component](card-view.component.md). | [Source](../lib/core/services/card-view-update.service.ts) | +| [Comment process service](comment-process.service.md) | Adds and retrieves comments for task and process instances in Process Services. | [Source](../lib/core/services/comment-process.service.ts) | +| [Content service](content.service.md) | Accesses app-generated data objects via URLs and file downloads. | [Source](../lib/core/services/content.service.ts) | +| [Cookie service](cookie.service.md) | Stores key-value data items as browser cookies. | [Source](../lib/core/services/cookie.service.ts) | +| [Deleted nodes api service](deleted-nodes-api.service.md) | Gets a list of Content Services nodes currently in the trash. | [Source](../lib/core/services/deleted-nodes-api.service.ts) | +| [Discovery api service](discovery-api.service.md) | Gets version and license information for Process Services and Content Services. | [Source](../lib/core/services/discovery-api.service.ts) | +| [Favorites api service](favorites-api.service.md) | Gets a list of items a user has marked as their favorites. | [Source](../lib/core/services/favorites-api.service.ts) | +| [Highlight transform service](highlight-transform.service.md) | Adds HTML to a string to highlight chosen sections. | [Source](../lib/core/services/highlight-transform.service.ts) | +| [Log service](log.service.md) | Provide a log functionality for your ADF application. | [Source](../lib/core/services/log.service.ts) | +| [Nodes api service](nodes-api.service.md) | Accesses and manipulates ACS document nodes using their node IDs. | [Source](../lib/core/services/nodes-api.service.ts) | +| [Notification service](notification.service.md) | Shows a notification message with optional feedback. | [Source](../lib/core/services/notification.service.ts) | +| [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) | +| [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) | +| [Storage service](storage.service.md) | Stores items in the form of key-value pairs. | [Source](../lib/core/services/storage.service.ts) | +| [Thumbnail service](thumbnail.service.md) | Retrieves an SVG thumbnail image to represent a document type. | [Source](../lib/core/services/thumbnail.service.ts) | +| [Translation service](translation.service.md) | Supports localisation. | [Source](../lib/core/services/translation.service.ts) | +| [Upload service](upload.service.md) | Provides access to various APIs related to file upload features. | [Source](../lib/core/services/upload.service.ts) | +| [User preferences service](user-preferences.service.md) | Stores preferences for components. | [Source](../lib/core/services/user-preferences.service.ts) | +| [Bpm user service](bpm-user.service.md) | Gets information about the current Process Services user. | [Source](../lib/core/userinfo/services/bpm-user.service.ts) | +| [Ecm user service](ecm-user.service.md) | Gets information about a Content Services user. | [Source](../lib/core/userinfo/services/ecm-user.service.ts) | +| _Renditions service_ | _Not currently documented_ | [Source](../lib/core/services/renditions.service.ts) | +| _Sites service_ | _Not currently documented_ | [Source](../lib/core/services/sites.service.ts) | -- [Content widget](content.widget.md) - +## Widgets + +| Name | Description | Source link | +| ----------------------------------- | ---------------------------------------- | ----------------------------------------------------------------------- | +| [Content widget](content.widget.md) | The component shows the content preview. | [Source](../lib/core/form/components/widgets/content/content.widget.ts) | + + ### Other classes and interfaces -- [DataTableAdapter interface](DataTableAdapter.md) -- [FormFieldValidator interface](FormFieldValidator.md) +| Name | Description | Source link | +| -- | -- | -- | +| [Data Table Adapter interface](DataTableAdapter.md) | Defines how table data is supplied to [DataTable](datatable.component.md) and [Tasklist](task-list.component.md) components. | [Source](../core/datatable/data/datatable-adapter.ts) | +| [Form Field Validator interface](FormFieldValidator.md) | Defines how the input fields of [ADF Form](form.component.md) and [ADF Task Details](task-details.component.md) components are validated. | [Source](../core/form/components/widgets/core/form-field-validator.ts) | [(Back to Contents)](#contents) @@ -145,52 +161,64 @@ Contains components related to Content Services. See the library's [README file](../lib/content-services/README.md) for more information about installing and using the source code. - -### Components + -- [Breadcrumb component](breadcrumb.component.md) -- [Dropdown breadcrumb component](dropdown-breadcrumb.component.md) -- [Content node selector component](content-node-selector.component.md) -- [Content action component](content-action.component.md) -- [Document list component](document-list.component.md) -- [Search control component](search-control.component.md) -- [Search component](search.component.md) -- [Sites dropdown component](sites-dropdown.component.md) -- [Like component](like.component.md) -- [Rating component](rating.component.md) -- [Tag actions component](tag-actions.component.md) -- [Tag list component](tag-list.component.md) -- [Tag node list component](tag-node-list.component.md) -- [File uploading dialog component](file-uploading-dialog.component.md) -- [Upload button component](upload-button.component.md) -- [Upload drag area component](upload-drag-area.component.md) -- [Version list component](version-list.component.md) -- [Version manager component](version-manager.component.md) -- [Webscript component](webscript.component.md) -- [*Content metadata card component](../lib/content-services/content-metadata/content-metadata-card.component.ts) -- [*Content metadata component](../lib/content-services/content-metadata/content-metadata.component.ts) +## Components -### Directives +| Name | Description | Source link | +| --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| [Breadcrumb component](breadcrumb.component.md) | Indicates the current position within a navigation hierarchy. | [Source](../lib/content-services/breadcrumb/breadcrumb.component.ts) | +| [Dropdown breadcrumb component](dropdown-breadcrumb.component.md) | Indicates the current position within a navigation hierarchy using a dropdown menu. | [Source](../lib/content-services/breadcrumb/dropdown-breadcrumb.component.ts) | +| [Content node selector component](content-node-selector.component.md) | Allows a user to select items from a Content Services repository. | [Source](../lib/content-services/content-node-selector/content-node-selector.component.ts) | +| [Content action component](content-action.component.md) | Adds options to a Document List actions menu for a particular content type. | [Source](../lib/content-services/document-list/components/content-action/content-action.component.ts) | +| [Document list component](document-list.component.md) | Displays the documents from a repository. | [Source](../lib/content-services/document-list/components/document-list.component.ts) | +| [Search control component](search-control.component.md) | Displays a input text which shows find-as-you-type suggestions. | [Source](../lib/content-services/search/components/search-control.component.ts) | +| [Search component](search.component.md) | You have to add a template that will be shown when the results are loaded. | [Source](../lib/content-services/search/components/search.component.ts) | +| [Sites dropdown component](sites-dropdown.component.md) | Displays a dropdown menu to show and interact with the sites of the current user. | [Source](../lib/content-services/site-dropdown/sites-dropdown.component.ts) | +| [Like component](like.component.md) | Allows a user to add "likes" to an item. | [Source](../lib/content-services/social/like.component.ts) | +| [Rating component](rating.component.md) | Allows a user to add ratings to an item. | [Source](../lib/content-services/social/rating.component.ts) | +| [Tag actions component](tag-actions.component.md) | Shows available actions for tags. | [Source](../lib/content-services/tag/tag-actions.component.ts) | +| [Tag list component](tag-list.component.md) | Shows tags for an item. | [Source](../lib/content-services/tag/tag-list.component.ts) | +| [Tag node list component](tag-node-list.component.md) | Shows tags for a node. | [Source](../lib/content-services/tag/tag-node-list.component.ts) | +| [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) | +| [Webscript component](webscript.component.md) | Another example: | [Source](../lib/content-services/webscript/webscript.component.ts) | +| _Content metadata card component_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/content-metadata-card.component.ts) | +| _Content metadata component_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/content-metadata.component.ts) | +| _Content node selector panel component_ | _Not currently documented_ | [Source](../lib/content-services/content-node-selector/content-node-selector-panel.component.ts) | -- [Folder create directive](folder-create.directive.md) -- [Folder edit directive](folder-edit.directive.md) -- [File draggable directive](file-draggable.directive.md) +## Directives -### Models +| Name | Description | Source link | +| ------------------------------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| [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) | -- [Document library model](document-library.model.md) -- [Permissions style model](permissions-style.model.md) +## Models -### Services +| Name | Description | Source link | +| ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| [Document library model](document-library.model.md) | Defines classes for use with the Content Services node API. | [Source](../lib/content-services/document-list/models/document-library.model.ts) | +| [Permissions style model](permissions-style.model.md) | Sets custom CSS styles for rows of a [Document List](document-list.component.md) according to the item's permissions. | [Source](../lib/content-services/document-list/models/permissions-style.model.ts) | -- [Document actions service](document-actions.service.md) -- [Document list service](document-list.service.md) -- [Folder actions service](folder-actions.service.md) -- [Rating service](rating.service.md) -- [Tag service](tag.service.md) -- [*Content metadata service](../lib/content-services/content-metadata/content-metadata.service.ts) - +## Services + +| Name | Description | Source link | +| ------------------------------------------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| [Document actions service](document-actions.service.md) | Implements the document menu actions for the Document List component. | [Source](../lib/content-services/document-list/services/document-actions.service.ts) | +| [Document list service](document-list.service.md) | Implements node operations used by the Document List component. | [Source](../lib/content-services/document-list/services/document-list.service.ts) | +| [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) | +| _Content metadata service_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/content-metadata.service.ts) | +| _Content node dialog service_ | _Not currently documented_ | [Source](../lib/content-services/content-node-selector/content-node-dialog.service.ts) | + + [(Back to Contents)](#contents) @@ -200,52 +228,61 @@ Contains components related to Process Services. See the library's [README file](../lib/process-services/README.md) for more information about installing and using the source code. - -### Components + -- [Apps list component](apps-list.component.md) -- [Create process attachment component](create-process-attachment.component.md) -- [Create task attachment component](create-task-attachment.component.md) -- [Process attachment list component](process-attachment-list.component.md) -- [Task attachment list component](task-attachment-list.component.md) -- [Comment list component](comment-list.component.md) -- [Comments component](comments.component.md) -- [Process comments component](process-comments.component.md) -- [People list component](people-list.component.md) -- [People search component](people-search.component.md) -- [People component](people.component.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) -- [Start process component](start-process.component.md) -- [Checklist component](checklist.component.md) -- [Start task component](start-task.component.md) -- [Task details component](task-details.component.md) -- [Task filters component](task-filters.component.md) -- [Task header component](task-header.component.md) -- [Task list component](task-list.component.md) +## Components -### Directives +| Name | Description | Source link | +| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| [Apps list component](apps-list.component.md) | Shows all available apps. | [Source](../lib/process-services/app-list/apps-list.component.ts) | +| [Create process attachment component](create-process-attachment.component.md) | Displays Upload Component (Drag and Click) to upload the attachment to a specified process instance | [Source](../lib/process-services/attachment/create-process-attachment.component.ts) | +| [Create task attachment component](create-task-attachment.component.md) | Displays Upload Component (Drag and Click) to upload the attachment to a specified task | [Source](../lib/process-services/attachment/create-task-attachment.component.ts) | +| [Process attachment list component](process-attachment-list.component.md) | Displays attached documents on a specified process instance | [Source](../lib/process-services/attachment/process-attachment-list.component.ts) | +| [Task attachment list component](task-attachment-list.component.md) | Displays attached documents on a specified task. | [Source](../lib/process-services/attachment/task-attachment-list.component.ts) | +| [Comment list component](comment-list.component.md) | Shows a list of comments. | [Source](../lib/process-services/comments/comment-list.component.ts) | +| [Comments component](comments.component.md) | Displays comments from users involved in a specified task and allows an involved user to add a comment to the task. | [Source](../lib/process-services/comments/comments.component.ts) | +| [Process comments component](process-comments.component.md) | Displays comments associated with a particular process instance and allows the user to add new comments | [Source](../lib/process-services/comments/process-comments.component.ts) | +| [People list component](people-list.component.md) | Shows a list of users (people). | [Source](../lib/process-services/people/people-list.component.ts) | +| [People search component](people-search.component.md) | Searches users/people. | [Source](../lib/process-services/people/people-search.component.ts) | +| [People component](people.component.md) | Displays involved users to a specified task | [Source](../lib/process-services/people/people.component.ts) | +| [Process filters component](process-filters.component.md) | Collection of criteria used to filter process instances, which may be customized by users. | [Source](../lib/process-services/process-list/components/process-filters.component.ts) | +| [Process instance details component](process-instance-details.component.md) | Displays detailed information on a specified process instance | [Source](../lib/process-services/process-list/components/process-instance-details.component.ts) | +| [Process instance header component](process-instance-header.component.md) | Sub-component of the process details component, which renders some general information about the selected process. | [Source](../lib/process-services/process-list/components/process-instance-header.component.ts) | +| [Process instance tasks component](process-instance-tasks.component.md) | Lists both the active and completed tasks associated with a particular process instance | [Source](../lib/process-services/process-list/components/process-instance-tasks.component.ts) | +| [Process list component](process-list.component.md) | This component renders a list containing all the process instances matched by the parameters specified. | [Source](../lib/process-services/process-list/components/process-list.component.ts) | +| [Start process component](start-process.component.md) | Starts a process. | [Source](../lib/process-services/process-list/components/start-process.component.ts) | +| [Checklist component](checklist.component.md) | Shows the checklist task functionality. | [Source](../lib/process-services/task-list/components/checklist.component.ts) | +| [Start task component](start-task.component.md) | Creates/Starts new task for the specified app | [Source](../lib/process-services/task-list/components/start-task.component.ts) | +| [Task details component](task-details.component.md) | Shows the details of the task id passed in input | [Source](../lib/process-services/task-list/components/task-details.component.ts) | +| [Task filters component](task-filters.component.md) | Shows all available filters. | [Source](../lib/process-services/task-list/components/task-filters.component.ts) | +| [Task header component](task-header.component.md) | Shows all the information related to a task. | [Source](../lib/process-services/task-list/components/task-header.component.ts) | +| [Task list component](task-list.component.md) | Renders a list containing all the tasks matched by the parameters specified. | [Source](../lib/process-services/task-list/components/task-list.component.ts) | -- [Process audit directive](process-audit.directive.md) -- [Task audit directive](task-audit.directive.md) +## Directives -### Models +| Name | Description | Source link | +| ----------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------ | +| [Process audit directive](process-audit.directive.md) | Fetches the Process Audit information in the pdf or json format. | [Source](../lib/process-services/process-list/components/process-audit.directive.ts) | +| [Task audit directive](task-audit.directive.md) | Fetches the Task Audit information in the pdf or json format. | [Source](../lib/process-services/task-list/components/task-audit.directive.ts) | -- [Filter model](filter.model.md) -- [Task details model](task-details.model.md) +## Models -### Services +| Name | Description | Source link | +| ------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------ | +| [Filter model](filter.model.md) | Contains classes related to filters in Process Services. | [Source](../lib/process-services/task-list/models/filter.model.ts) | -- [Process filter service](process-filter.service.md) -- [Process service](process.service.md) -- [Task filter service](task-filter.service.md) -- [Tasklist service](tasklist.service.md) -- [*Task upload service](../lib/process-services/task-list/services/task-upload.service.ts) - +## Services + +| Name | Description | Source link | +| --------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| [Process filter service](process-filter.service.md) | Manage Process Filters, which are pre-configured Process Instance queries. | [Source](../lib/process-services/process-list/services/process-filter.service.ts) | +| [Process service](process.service.md) | Manage Process Instances, Process Variables, and Process Audit Log. | [Source](../lib/process-services/process-list/services/process.service.ts) | +| [Task filter service](task-filter.service.md) | Manage Task Filters, which are pre-configured Task Instance queries. | [Source](../lib/process-services/task-list/services/task-filter.service.ts) | +| [Tasklist service](tasklist.service.md) | Manage Task Instances. | [Source](../lib/process-services/task-list/services/tasklist.service.ts) | +| _Task upload service_ | _Not currently documented_ | [Source](../lib/process-services/task-list/services/task-upload.service.ts) | + + [(Back to Contents)](#contents) @@ -255,15 +292,19 @@ Contains components for Process Services analytics and diagrams. See the library's [README file](../lib/insights/README.md) for more information about installing and using the source code. - -### Components + -- [Analytics generator component](analytics-generator.component.md) -- [Analytics report list component](analytics-report-list.component.md) -- [Analytics component](analytics.component.md) -- [Widget component](widget.component.md) -- [Diagram component](diagram.component.md) - +## Components -[(Back to Contents)](#contents) \ No newline at end of file +| Name | Description | Source link | +| --------------------------------------------------------------------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| [Widget component](widget.component.md) | Base class for standard and custom widget classes. | [Source](../lib/insights/analytics-process/components/widgets/widget.component.ts) | +| [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) | + + + +[(Back to Contents)](#contents) diff --git a/docs/activiti-alfresco.service.md b/docs/activiti-alfresco.service.md index cc14a55758..d90b47d8ee 100644 --- a/docs/activiti-alfresco.service.md +++ b/docs/activiti-alfresco.service.md @@ -1,6 +1,7 @@ # Activiti Alfresco Content Service -Get Alfresco Repository folder content based on a Repository account configured in Alfresco Process Services (APS). +Gets Alfresco Repository folder content based on a Repository account configured in Alfresco Process Services (APS). + It is possible to configure multiple Alfresco Repository accounts in APS (i.e. multiple Alfresco Servers). This service can also be used to link Alfresco content as related content in APS. Content such as documents and other files can be attached to Process Instances diff --git a/docs/folder-create.directive.md b/docs/folder-create.directive.md index 339f1e60b6..bc393438d0 100644 --- a/docs/folder-create.directive.md +++ b/docs/folder-create.directive.md @@ -1,17 +1,6 @@ # Folder Create directive - - - - -- [Basic Usage](#basic-usage) - * [Properties](#properties) - * [Events](#events) -- [Details](#details) - - - - +Allows folders to be created. ## Basic Usage diff --git a/docs/folder-edit.directive.md b/docs/folder-edit.directive.md index 14f1469fba..e748aa9194 100644 --- a/docs/folder-edit.directive.md +++ b/docs/folder-edit.directive.md @@ -1,17 +1,6 @@ # Folder Edit directive - - - - -- [Basic Usage](#basic-usage) - * [Properties](#properties) - * [Events](#events) -- [Details](#details) - - - - +Allows folders to be edited. ## Basic Usage diff --git a/docs/form-field.model.md b/docs/form-field.model.md index 621fd765fa..3416b0d9d3 100644 --- a/docs/form-field.model.md +++ b/docs/form-field.model.md @@ -1,7 +1,6 @@ # Form Field model -Contains the value and metadata for a field of an -[ADF Form](form.component.md). +Contains the value and metadata for a field of an [ADF Form](form.component.md). ## Properties diff --git a/docs/host-settings.component.md b/docs/host-settings.component.md index 59149c96c5..1a34fc5001 100644 --- a/docs/host-settings.component.md +++ b/docs/host-settings.component.md @@ -1,7 +1,6 @@ # Host settings component -This component is a form that allows you to validate and set the url of your content service and process service saving -it in the user local storage +Validates the URLs for ACS and APS and saves them in the user's local storage ![Host settings](docassets/images/host-settings-component.png) diff --git a/docs/like.component.md b/docs/like.component.md index eedaba6187..dc99eb84b1 100644 --- a/docs/like.component.md +++ b/docs/like.component.md @@ -1,5 +1,7 @@ # ADF Like component +Allows a user to add "likes" to an item. + ![Custom columns](docassets/images/social1.png) ## Basic Usage diff --git a/docs/node-restore.directive.md b/docs/node-restore.directive.md index 0a6d04f2b5..5927150ff4 100644 --- a/docs/node-restore.directive.md +++ b/docs/node-restore.directive.md @@ -1,5 +1,7 @@ # Node Restore directive +Restores deleted nodes to their original location. + ## Basic Usage ```html diff --git a/docs/node.service.md b/docs/node.service.md index 13bb79c4a9..937f92763c 100644 --- a/docs/node.service.md +++ b/docs/node.service.md @@ -1,5 +1,6 @@ # Node Service -Get Alfresco Repository node metadata and create nodes with metadata. +Gets Alfresco Repository node metadata and creates nodes with metadata. + This service cannot be used to create nodes with content. ## Importing diff --git a/docs/process-content.service.md b/docs/process-content.service.md index 1944d6c0dd..471031ebbe 100644 --- a/docs/process-content.service.md +++ b/docs/process-content.service.md @@ -1,6 +1,7 @@ # Process Content Service -Manipulate content related to a Process Instance or Task Instance in APS. Related content can be -uploaded to APS via for example a file upload dialog. +Manipulates content related to a Process Instance or Task Instance in APS. + +Related content can be uploaded to APS via for example a file upload dialog. ## Importing diff --git a/docs/rating.component.md b/docs/rating.component.md index 0ec88269a5..786e439c57 100644 --- a/docs/rating.component.md +++ b/docs/rating.component.md @@ -1,5 +1,7 @@ # ADF Rating component +Allows a user to add ratings to an item. + ![Rating component screenshot](docassets/images/social2.png) ## Basic Usage diff --git a/docs/start-process.component.md b/docs/start-process.component.md index 6d4b0983de..45d0809914 100644 --- a/docs/start-process.component.md +++ b/docs/start-process.component.md @@ -1,6 +1,6 @@ # Start Process component -Displays Start Process, allowing the user to specify some details like process name and process definition, which are the most basic requirement to start a new process instance. The user have to select the process definition from a dropdown if there are more than one process definition available. If there is just one process definition available for the app, then it is auto-selected. There is a error message shown if no process definition is available. +Starts a process. ![adf-start-process ](docassets/images/startProcess.png) @@ -26,3 +26,7 @@ Displays Start Process, allowing the user to specify some details like process n | start | Raised when the process start | | cancel | Raised when the process canceled | | error | Raised when the start process fail | + +## Details + +Displays Start Process, allowing the user to specify some details like process name and process definition, which are the most basic requirement to start a new process instance. The user have to select the process definition from a dropdown if there are more than one process definition available. If there is just one process definition available for the app, then it is auto-selected. There is a error message shown if no process definition is available. \ No newline at end of file diff --git a/docs/tag-actions.component.md b/docs/tag-actions.component.md index 1be68f1399..eb247e837b 100644 --- a/docs/tag-actions.component.md +++ b/docs/tag-actions.component.md @@ -1,5 +1,7 @@ # Alfresco Tag Node Actions List component +Shows available actions for tags. + ![Custom columns](docassets/images/tag3.png) ## Basic Usage diff --git a/docs/tag-list.component.md b/docs/tag-list.component.md index 46214d914f..7d005fe86a 100644 --- a/docs/tag-list.component.md +++ b/docs/tag-list.component.md @@ -1,3 +1,5 @@ # Alfresco Tag List component +Shows tags for an item. + ![Custom columns](docassets/images/tag2.png) \ No newline at end of file diff --git a/docs/tag-node-list.component.md b/docs/tag-node-list.component.md index 25ec81dba5..335c95b93a 100644 --- a/docs/tag-node-list.component.md +++ b/docs/tag-node-list.component.md @@ -1,5 +1,7 @@ # Alfresco Tag Node List component +Shows tags for a node. + ![Custom columns](docassets/images/tag1.png) ## Basic Usage diff --git a/docs/upload-button.component.md b/docs/upload-button.component.md index be6b899d40..363a877bf5 100644 --- a/docs/upload-button.component.md +++ b/docs/upload-button.component.md @@ -1,5 +1,7 @@ # Upload Button Component +Activates a file upload. + ## Basic Usage ```html diff --git a/docs/user-info.component.md b/docs/user-info.component.md index 6157a3690d..0eecc0ab2f 100644 --- a/docs/user-info.component.md +++ b/docs/user-info.component.md @@ -1,5 +1,7 @@ # Alfresco User Info component +Shows user information. + ## Basic usage ```html diff --git a/docs/version-list.component.md b/docs/version-list.component.md index 8a9abe2a48..200099ddb6 100644 --- a/docs/version-list.component.md +++ b/docs/version-list.component.md @@ -1,7 +1,6 @@ # Version List component -Displays the version history of a node in a -[Version Manager component](version-manager.component.md) +Displays the version history of a node in a [Version Manager component](version-manager.component.md) ### Basic Usage diff --git a/lib/config/DocProcessor/docProcessor.js b/lib/config/DocProcessor/docProcessor.js new file mode 100644 index 0000000000..78b20c4b5f --- /dev/null +++ b/lib/config/DocProcessor/docProcessor.js @@ -0,0 +1,175 @@ +var fs = require("fs"); +var path = require("path"); +var program = require("commander"); + +var remark = require("remark"); +var parse = require("remark-parse"); +var stringify = require("remark-stringify"); + +/* +var managetoc = require("./managetoc"); +var sa = require("./seealso"); +var index = require("./index"); +*/ + +// "Aggregate" data collected over the whole file set. +var aggData = {}; + +var toolsFolderName = "tools"; +var configFileName = "doctool.config.json"; + + +function initPhase(aggData) { + /* + toolModules.seealso.initPhase(aggData); + toolModules.index.initPhase(aggData); + */ + + toolList.forEach(toolName => { + toolModules[toolName].initPhase(aggData); + }); +} + + +function readPhase(srcFolder, filenames, aggData) { + for (var i = 0; i < filenames.length; i++) { + var pathname = path.resolve(srcFolder, filenames[i]); + + var src = fs.readFileSync(pathname); + var tree = remark().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)); +} + + +function aggPhase(aggData) { + toolList.forEach(toolName => { + toolModules[toolName].aggPhase(aggData); + }); + + /* + toolModules.seealso.aggPhase(aggData); + toolModules.index.aggPhase(aggData); + */ +} + + +function updatePhase(srcFolder, destFolder, filenames, aggData) { + for (var i = 0; i < filenames.length; i++) { + var pathname = path.resolve(srcFolder, filenames[i]); + + var src = fs.readFileSync(pathname); + var tree = remark().parse(src) + + var modified = false; + + toolList.forEach(toolName => { + modified |= toolModules[toolName].updatePhase(tree, pathname, aggData); + }); + + if (modified) + fs.writeFileSync(path.resolve(destFolder, filenames[i]), remark().stringify(tree)); + + //console.log(JSON.stringify(tree)); + } +} + + +function loadToolModules() { + var mods = {}; + var toolsFolderPath = path.resolve(__dirname, toolsFolderName); + var modFiles = fs.readdirSync(toolsFolderPath); + + for (var i = 0; i < modFiles.length; i++) { + var modPath = path.resolve(toolsFolderPath, modFiles[i]) + + if (path.extname(modPath) === ".js") { + var toolName = path.basename(modPath, ".js"); + mods[toolName] = require(modPath); + } + } + + return mods; +} + + +function loadToolConfig(configFilePath) { + var config = JSON.parse(fs.readFileSync(configFilePath)); + + return config.enabledTools; +} + + +program +.usage("[options] [dest]") +.parse(process.argv); + +if (program.args.length === 0) { + console.log("Error: source argument required"); + return 0; +} + + +var sourcePath = path.resolve(program.args[0]); +var sourceInfo = fs.statSync(sourcePath); + +var destPath; +var destInfo; + +if (program.args.length >= 2) { + destPath = path.resolve(program.args[1]); + destInfo = fs.statSync(sourcePath); +} else { + destPath = sourcePath; + destInfo = sourceInfo; +} + +if (sourceInfo.isDirectory() && !destInfo.isDirectory()) { + console.log("Error: The argument must be a directory"); + return 0; +} + +var toolModules = loadToolModules(); +var toolList = loadToolConfig(path.resolve(__dirname, configFileName)); + + +var files; + +if (sourceInfo.isDirectory()) { + files = fs.readdirSync(sourcePath); +} else if (sourceInfo.isFile()) { + files = [ path.basename(sourcePath) ]; + sourcePath = path.dirname(sourcePath); +} + +files = files.filter(filename => + (path.extname(filename) === ".md") && + (filename !== "README.md") +); + +//files.forEach(element => console.log(element)); + +console.log("Initialising..."); +initPhase(aggData); + +console.log("Analysing Markdown files..."); +readPhase(sourcePath, files, aggData); + +console.log("Computing aggregate data..."); +aggPhase(aggData); + +console.log("Updating Markdown files..."); +updatePhase(sourcePath, destPath, files, aggData); + + + diff --git a/lib/config/DocProcessor/doctool.config.json b/lib/config/DocProcessor/doctool.config.json new file mode 100644 index 0000000000..6f7ef23478 --- /dev/null +++ b/lib/config/DocProcessor/doctool.config.json @@ -0,0 +1,5 @@ +{ + "enabledTools": [ + "index" + ] +} \ No newline at end of file diff --git a/lib/config/DocProcessor/ngHelpers.js b/lib/config/DocProcessor/ngHelpers.js new file mode 100644 index 0000000000..961234fc2a --- /dev/null +++ b/lib/config/DocProcessor/ngHelpers.js @@ -0,0 +1,19 @@ +module.exports = { + "ngNameToDisplayName": ngNameToDisplayName, + "dekebabifyName": dekebabifyName, + "classTypes": ["component", "directive", "model", "pipe", "service", "widget"] +} + + +function ngNameToDisplayName(ngName) { + var mainSections = ngName.split("."); + mainSections[0] = dekebabifyName(mainSections[0]); + return mainSections.join(" "); +} + + +function dekebabifyName(name) { + var result = name.replace(/-/g, " "); + result = result.substr(0, 1).toUpperCase() + result.substr(1); + return result; +} \ No newline at end of file diff --git a/lib/config/DocProcessor/tools/index.js b/lib/config/DocProcessor/tools/index.js new file mode 100644 index 0000000000..7b11d68e38 --- /dev/null +++ b/lib/config/DocProcessor/tools/index.js @@ -0,0 +1,362 @@ +var fs = require("fs"); +var path = require("path"); + +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 searchFolderOmitRegex = /(config)|(mock)|(i18n)|(assets)|(styles)/; + +var docsFolderPath = path.resolve("..", "docs"); +var undocStoplistFileName = path.resolve(docsFolderPath, "undocStoplist.json"); +var rootFolder = "."; +var indexMdFilePath = path.resolve(docsFolderPath, "README.md"); +var guideSummaryFileName = path.resolve(docsFolderPath, "summary.json"); + +var maxBriefDescLength = 180; + +var adfLibNames = ["core", "content-services", "insights", "process-services"]; + + +function initPhase(aggData) { + aggData.stoplist = makeStoplist(undocStoplistFileName); + aggData.srcData = {}; + aggData.mdFileDesc = []; + + searchLibraryRecursive(aggData.srcData, path.resolve(rootFolder)); + + //console.log(JSON.stringify(aggData.srcData)); +} + + +function readPhase(tree, pathname, aggData) { + var itemName = path.basename(pathname, ".md"); + + // Look for the first paragraph in the file by skipping other items. + // Should usually be a position 1 in the tree. + var s; + var briefDesc; + + for ( + s = 0; + (s < tree.children.length) && !unist.isParagraph(tree.children[s]); + s++ + ); + + if (s < tree.children.length) { + briefDesc = tree.children[s]; + } + + aggData.mdFileDesc[itemName] = briefDesc; +} + +function aggPhase(aggData) { + var sections = prepareIndexSections(aggData); + //console.log(JSON.stringify(sections)); + + var indexFileText = fs.readFileSync(indexMdFilePath, "utf8"); + var indexFileTree = remark().parse(indexFileText); + + for (var l = 0; l < adfLibNames.length; l++) { + + var libName = adfLibNames[l]; + var libSection = sections[libName]; + + var md = makeLibSectionMD(libSection); + + zone(indexFileTree, libName, (startComment, oldSection, endComment) => { + md.unshift(startComment); + md.push(endComment); + return md; + }); + } + + var guideSection = buildGuideSection(guideSummaryFileName); + + zone(indexFileTree, "guide", (startComment, oldSection, endComment) => { + return [ + startComment, guideSection, endComment + ] + }); + + fs.writeFileSync(path.resolve("..", "docs", "README.md"), remark().stringify(indexFileTree)); + //fs.writeFileSync(indexMdFilePath, remark().stringify(indexFileTree)); + //fs.writeFileSync(path.resolve(".", "testJson.md"), JSON.stringify(indexFileTree)); +} + + +function updatePhase(tree, pathname, aggData) { + return false; +} + + +// Create a stoplist of regular expressions. +function makeStoplist(slFilePath) { + var listExpressions = JSON.parse(fs.readFileSync(slFilePath, 'utf8')); + + var result = []; + + for (var i = 0; i < listExpressions.length; i++) { + result.push(new RegExp(listExpressions[i])); + } + + return result; +} + +// Check if an item is covered by the stoplist and reject it if so. +function rejectItemViaStoplist(stoplist, itemName) { + for (var i = 0; i < stoplist.length; i++) { + if (stoplist[i].test(itemName)) { + return true; + } + } + + return false; +} + + +// Search source folders for .ts files to discover all components, directives, etc. +function searchLibraryRecursive(srcData, folderPath) { + var items = fs.readdirSync(folderPath); + + for (var i = 0; i < items.length; i++) { + var itemPath = path.resolve(folderPath, items[i]); + var info = fs.statSync(itemPath); + + if (info.isFile() && (items[i].match(angFilenameRegex))) { + var nameNoSuffix = path.basename(items[i], '.ts'); + + var displayPath = itemPath.replace(/\\/g, '/'); + displayPath = displayPath.substr(displayPath.indexOf("lib") + 4); + + // Type == "component", "directive", etc. + var itemType = nameNoSuffix.split('.')[1]; + + srcData[nameNoSuffix] = { "path": displayPath, "type": itemType }; + } else if (info.isDirectory() && !items[i].match(searchFolderOmitRegex)) { + searchLibraryRecursive(srcData, itemPath); + } + } +} + + +function prepareIndexSections(aggData) { + var srcNames = Object.keys(aggData.srcData); + var sections = initEmptySections(); + + for (var i = 0; i < srcNames.length; i++) { + var itemName = srcNames[i]; + var srcData = aggData.srcData[itemName]; + var libName = srcData.path.substr(0, srcData.path.indexOf("/")); + + var briefDesc = aggData.mdFileDesc[itemName]; + + var displayName = ngHelpers.ngNameToDisplayName(itemName); + + if (briefDesc) { + sections[libName][srcData.type].documented.push({ + "displayName": displayName, + "mdName": itemName + ".md", + "srcPath": srcData.path, + "briefDesc": briefDesc + }); + } else if (!rejectItemViaStoplist(aggData.stoplist, itemName)) { + sections[libName][srcData.type].undocumented.push({ + "displayName": displayName, + "mdName": itemName + ".md", + "srcPath": srcData.path + }); + } + } + + return sections; +} + + +function initEmptySections() { + var result = {}; + + for (var l = 0; l < adfLibNames.length; l++) { + var lib = result[adfLibNames[l]] = {}; + + for (var c = 0; c < ngHelpers.classTypes.length; c++) { + var classType = lib[ngHelpers.classTypes[c]] = {}; + + classType.undocumented = []; + classType.documented = []; + } + } + + return result; +} + + +function buildMDDocumentedSection(docItems) { + var listItems = []; + + for (var i = 0; i < docItems.length; i++) { + listItems.push(makeMDDocumentedListItem(docItems[i])); + } + + return unist.makeListUnordered(listItems); +} + + +function buildMDUndocumentedSection(docItems) { + var listItems = []; + + for (var i = 0; i < docItems.length; i++) { + listItems.push(makeMDUndocumentedListItem(docItems[i])); + } + + return unist.makeListUnordered(listItems); +} + + +function buildMDDocumentedTable(docItems) { + var rows = [ + + ]; + + for (var i = 0; i < docItems.length; i++) { + rows.push(makeMDDocumentedTableRow(docItems[i])); + } + + return rows; + //return unist.makeTable([null, null, null, null], rows); +} + + +function buildMDUndocumentedTable(docItems) { + var rows = [ + + ]; + + for (var i = 0; i < docItems.length; i++) { + rows.push(makeMDUndocumentedTableRow(docItems[i])); + } + + return rows; + //return unist.makeTable([null, null, null, null], rows); +} + + +function makeMDDocumentedListItem(docItem) { + var mdFileLink = unist.makeLink(unist.makeText(docItem.displayName), docItem.mdName); + var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath); + var desc = docItem.briefDesc; + + var para = unist.makeParagraph([ + mdFileLink, unist.makeText(" ("), srcFileLink, unist.makeText(") "), desc + ]); + + return unist.makeListItem(para); +} + + +function makeMDUndocumentedListItem(docItem) { + var itemName = unist.makeText(docItem.displayName); + var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath); + + var para = unist.makeParagraph([ + unist.makeText("* "), itemName, unist.makeText(" ("), srcFileLink, unist.makeText(")") + ]); + + return unist.makeListItem(para); +} + + +function makeMDDocumentedTableRow(docItem) { + var mdFileLink = unist.makeLink(unist.makeText(docItem.displayName), docItem.mdName); + var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath); + var desc = docItem.briefDesc; + + return unist.makeTableRow([ + unist.makeTableCell([mdFileLink]), + unist.makeTableCell([desc]), + unist.makeTableCell([srcFileLink]) + ]); +} + + +function makeMDUndocumentedTableRow(docItem) { + var itemName = unist.makeText(docItem.displayName); + var srcFileLink = unist.makeLink(unist.makeText("Source"), "../lib/" + docItem.srcPath); + + return unist.makeTableRow([ + unist.makeTableCell([unist.makeEmphasis([itemName])]), + unist.makeTableCell([unist.makeEmphasis([unist.makeText("Not currently documented")])]), + unist.makeTableCell([srcFileLink]) + ]); +} + + +function makeLibSectionMD(libSection){ + var md = []; + + var libClassTypes = Object.keys(libSection); + + for (var i = 0; i < libClassTypes.length; i++) { + var classType = libClassTypes[i]; + + var classSection = libSection[classType]; + + if (!classSection) + continue; + + var displayNameNode; + + if ((classSection.documented.length > 0) || (classSection.undocumented.length > 0)) { + displayNameNode = unist.makeText(ngHelpers.dekebabifyName(classType + "s")); + md.push(unist.makeHeading(displayNameNode, 2)); + + var tableRows = [ + unist.makeTableRow([ + unist.makeTableCell([unist.makeText("Name")]), + unist.makeTableCell([unist.makeText("Description")]), + unist.makeTableCell([unist.makeText("Source link")]) + ]) + ]; + + if (classSection.documented.length > 0) { + //md.push(buildMDDocumentedSection(classSection.documented)); + tableRows = tableRows.concat(buildMDDocumentedTable(classSection.documented)); + } + + if (classSection.undocumented.length > 0) { + // md.push(buildMDUndocumentedSection(classSection.undocumented)); + tableRows = tableRows.concat(buildMDUndocumentedTable(classSection.undocumented)); + } + + md.push(unist.makeTable([null, null, null, null], tableRows)); + } + } + + return md; +} + + +function buildGuideSection(guideJsonFilename) { + var summary = JSON.parse(fs.readFileSync(guideJsonFilename, "utf8")); + + var listItems = []; + + for (var i = 0; i < summary.length; i++) { + var link = unist.makeLink(unist.makeText(summary[i].title), summary[i].file); + listItems.push(unist.makeListItem(link)); + } + + return unist.makeListUnordered(listItems); +} \ No newline at end of file diff --git a/lib/config/DocProcessor/tools/seealso.js b/lib/config/DocProcessor/tools/seealso.js new file mode 100644 index 0000000000..47d998370a --- /dev/null +++ b/lib/config/DocProcessor/tools/seealso.js @@ -0,0 +1,175 @@ +var path = require("path"); +var getSection = require("mdast-util-heading-range"); + +var unist = require("../unistHelpers"); + +var seeAlsoHeading = "See Also"; + +module.exports = { + "initPhase": initPhase, + "readPhase": readPhase, + "aggPhase": aggPhase, + "updatePhase": updatePhase +} + + +function initPhase(aggData) { + aggData.saGraph = {}; + aggData.saUpdateGraph = {}; +} + + +function readPhase(tree, pathname, aggData) { + var saHeadingOffset = findSeeAlsoSection(tree); + + var saNode = []; + + if (saHeadingOffset !== -1) { + // Skip over non-list parts. + var s; + + for ( + s = saHeadingOffset; + (s < tree.children.length) && !unist.isListUnordered(tree.children[s]); + s++ + ); + + if ((s < tree.children.length) && unist.isListUnordered(tree.children[s])) { + var list = tree.children[s]; + + for (var i = 0; i < list.children.length; i++) { + var itemLink = getItemLinkInfo(list.children[i]); + + if (itemLink) { + saNode.push(itemLink); + } + } + } + } + + aggData.saGraph[path.basename(pathname, ".md")] = saNode; +} + + +function aggPhase(aggData) { + aggData.saUpdateGraph = tidyGraph(aggData.saGraph); +} + + +function updatePhase(tree, pathname, aggData) { + var currNodeName = path.basename(pathname, ".md"); + var currNodeArcs = aggData.saUpdateGraph[currNodeName]; + + if (currNodeArcs.length > 0) { + var saListItems = []; + + for (var i = 0; i < currNodeArcs.length; i++) { + var linkText = graphKeyToLinkName(currNodeArcs[i]); + var linkTarget = currNodeArcs[i] + ".md"; + var link = unist.makeLink(unist.makeText(linkText), linkTarget); + saListItems.push(unist.makeListItem(link)); + } + + var saHeadingOffset = findSeeAlsoSection(tree); + + if (saHeadingOffset !== -1) { + // Skip over non-list parts. + var s; + + for ( + s = saHeadingOffset; + (s < tree.children.length) && !unist.isListUnordered(tree.children[s]); + s++ + ); + + // Push all elements of the items array as if they were separate elements. + Array.prototype.push.apply(tree.children[s].children, saListItems); + } else { + // This file doesn't currently have a See Also section, so add one at the end. + tree.children.push(unist.makeHeading(unist.makeText(seeAlsoHeading), 2)); + tree.children.push(unist.makeListUnordered(saListItems)); + } + } + + return true; +} + + +function graphKeyToLinkName(key) { + var mainSections = key.split("."); + mainSections[0] = tidyName(mainSections[0]); + return mainSections.join(" "); +} + +// Convert an Angular-style name (eg, "card-view") into one with correct spaces and uppercase (eg, "Card view"). +function tidyName(name) { + var result = name.replace(/-/g, " "); + result = result.substr(0, 1).toUpperCase() + result.substr(1); + return result; +} + + +function makeEmptySAList() { + var result = []; + + +} + + +// Makes link symmetrical between items (ie, if A links to B but not the other way +// around then it adds the missing link). +function tidyGraph(graph) { + var nodeNames = Object.keys(graph); + var result = {}; + + for (var n = 0; n < nodeNames.length; n++) { + result[nodeNames[n]] = []; + } + + for (var n = 0; n < nodeNames.length; n++) { + var currNodeName = nodeNames[n]; + + var currNodeArcs = graph[currNodeName]; + + for (var a = 0; a < currNodeArcs.length; a++) { + var linkedNode = graph[currNodeArcs[a]]; + var resultNode = result[currNodeArcs[a]]; + + if (!linkedNode) { + console.log(`Warning: item '${currNodeArcs[a]}' (in See Also section of '${currNodeName}') has no corresponding file`); + } else if (linkedNode.indexOf(currNodeName) === -1) { + linkedNode.push(currNodeName); + resultNode.push(currNodeName); + } + } + } + + return result; +} + + +function findSeeAlsoSection(tree) { + var i; + + for (i = 0; i < tree.children.length; i++) { + var child = tree.children[i]; + + if (unist.isHeading(child) && (child.children[0].value.toLowerCase() === seeAlsoHeading.toLowerCase())) + return i; + } + + return -1; +} + + +function getItemLinkInfo(listItem) { + var linkTarget = listItem.children[0].children[0].url; + + if (linkTarget.startsWith("http:") || + linkTarget.startsWith("#") || + !linkTarget.endsWith(".md")) + return null; + else + return path.basename(linkTarget, ".md"); +} + diff --git a/lib/config/DocProcessor/tools/toc.js b/lib/config/DocProcessor/tools/toc.js new file mode 100644 index 0000000000..e6f727153e --- /dev/null +++ b/lib/config/DocProcessor/tools/toc.js @@ -0,0 +1,82 @@ +var remark = require("remark"); +var tocGenerator = require("mdast-util-toc"); +var replaceSection = require("mdast-util-heading-range"); + +var unist = require("../unistHelpers"); + +const contentsHeading = "Contents"; +const minHeadingsForToc = 8; +const maxTocHeadingDepth = 3; + +module.exports = process; + +// Find an existing Contents section or add a new empty one if needed. +// Returns true if section is present/needed, false if not needed. +function establishContentsSection(mdTree) { + var firstL2HeadingPos = -1; + var numTocHeadings = 0; + var foundContentsHeading = false; + + for (var i = 0; i < mdTree.children.length; i++) { + var child = mdTree.children[i]; + + // Look through all headings. + if (child.type === "heading") { + + if ((child.depth > 1) && (child.depth <= maxTocHeadingDepth)) { + numTocHeadings++; + } + + if (child.depth === 2) { + // Note where the first L2 heading is. + if (firstL2HeadingPos === -1) { + firstL2HeadingPos = i; + } + + // If it is also a Contents heading then we're done. We don't include the + // Contents heading itself within the ToC, so decrement the count for that. + if ((child.children[0].value === contentsHeading) && !foundContentsHeading) { + foundContentsHeading = true; + numTocHeadings--; + } + } + } + } + + // If we get here then a level 2 Contents heading was not found. + // If there are enough headings for a ToC to be necessary then + // add one in the right place. + if (!foundContentsHeading) { + var newContsHeading = unist.makeHeading(contentsHeading, 2); + + // If we found another L2 heading then add the Contents in just before it. + if (firstL2HeadingPos != -1) { + mdTree.children.splice(firstL2HeadingPos, 0, newContsHeading); + } else { + // Otherwise, the unlikely situation where a ToC is required but there + // are no L2 headings! Add it as the second element in the document. + mdTree.children.splice(1, 0, newContsHeading); + } + } + + return numTocHeadings; +} + + +function process(mdTree, file) { +// If we need a contents section then add one or update the existing one. + var numTocHeadings = establishContentsSection(mdTree); + + if (numTocHeadings >= minHeadingsForToc) { + var newToc = tocGenerator(mdTree, {heading: contentsHeading, maxDepth: 3}); + + replaceSection(mdTree, contentsHeading, function(before, oldSection, after) { + return [before, newToc.map, after]; + }); + } else { + // Otherwise, we don't need one, so remove any existing one. + replaceSection(mdTree, contentsHeading, function(before, oldSection, after) { + return [after]; + }); + } +} \ No newline at end of file diff --git a/lib/config/DocProcessor/tools/tscProps.js b/lib/config/DocProcessor/tools/tscProps.js new file mode 100644 index 0000000000..a0143a865f --- /dev/null +++ b/lib/config/DocProcessor/tools/tscProps.js @@ -0,0 +1,181 @@ +"use strict"; +exports.__esModule = true; +var ts = require("typescript"); +var path = require("path"); +var program = require("commander"); +var heading = require("mdast-util-heading-range"); +var unist = require("../unistHelpers"); +function initPhase(aggData) { +} +exports.initPhase = initPhase; +function readPhase(tree, pathname, aggData) { +} +exports.readPhase = readPhase; +function aggPhase(aggData) { +} +exports.aggPhase = aggPhase; +function updatePhase(tree, pathname, aggData) { + var fileNameNoSuffix = path.basename(pathname, ".md"); + if (fileNameNoSuffix.match(/component/)) { + var srcData = aggData.srcData[fileNameNoSuffix]; + if (srcData) { + var srcPath = srcData.path; + var className = fixCompodocFilename(fileNameNoSuffix); + var inputs = []; + var outputs = []; + getPropDocData(path.resolve(".", srcPath), className, inputs, outputs); + var inTable_1 = buildInputsTable(inputs); + var outTable_1 = buildOutputsTable(outputs); + if (inTable_1) { + console.log("Made a props table"); + heading(tree, "Properties", function (before, section, after) { + return [before, inTable_1, after]; + }); + } + if (outTable_1) { + console.log("Made an events table"); + heading(tree, "Events", function (before, section, after) { + return [before, outTable_1, after]; + }); + } + } + } +} +exports.updatePhase = updatePhase; +function initialCap(str) { + return str[0].toUpperCase() + str.substr(1); +} +function fixCompodocFilename(rawName) { + var name = rawName.replace(/\]|\(|\)/g, ''); + var fileNameSections = name.split('.'); + var compNameSections = fileNameSections[0].split('-'); + var outCompName = ''; + for (var i = 0; i < compNameSections.length; i++) { + outCompName = outCompName + initialCap(compNameSections[i]); + } + var itemTypeIndicator = ''; + if (fileNameSections.length > 1) { + itemTypeIndicator = initialCap(fileNameSections[1]); + } + var finalName = outCompName + itemTypeIndicator; + return finalName; +} +function getPropDocData(srcPath, docClassName, inputs, outputs) { + var prog = ts.createProgram(program.args, { + target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS + }); + var sourceFiles = prog.getSourceFiles(); + var checker = prog.getTypeChecker(); + for (var i = 0; i < sourceFiles.length; i++) { + if (!sourceFiles[i].isDeclarationFile) + ts.forEachChild(sourceFiles[i], visit); + } + function visit(node) { + if (!isNodeExported(node)) + return; + if (ts.isClassDeclaration(node) && node.name) { + var classDec = node; + var sourceFile = classDec.getSourceFile(); + if (classDec.name.escapedText === docClassName) { + getPropDataFromClass(checker, classDec, inputs, outputs); + } + } + } +} +function getPropDataFromClass(checker, classDec, inputs, outputs) { + var sourceFile = classDec.getSourceFile(); + for (var i = 0; i < classDec.members.length; i++) { + var member = classDec.members[i]; + if (ts.isPropertyDeclaration(member)) { + var prop = member; + var mods = ts.getCombinedModifierFlags(prop); + var nonPrivate = (mods & ts.ModifierFlags.Private) === 0; + var memSymbol = checker.getSymbolAtLocation(prop.name); + if (nonPrivate && memSymbol && prop.decorators) { + var name_1 = memSymbol.getName(); + var initializer = ""; + if (prop.initializer) { + initializer = prop.initializer.getText(sourceFile); + } + var doc = ts.displayPartsToString(memSymbol.getDocumentationComment()); + var propType = checker.typeToString(checker.getTypeOfSymbolAtLocation(memSymbol, memSymbol.valueDeclaration)); + var dec = prop.decorators[0].getText(sourceFile); + if (dec.match(/@Input/)) { + inputs.push({ + "name": name_1, + "type": propType, + "init": initializer, + "docText": doc + }); + } + else if (dec.match(/@Output/)) { + outputs.push({ + "name": name_1, + "type": propType, + "docText": doc + }); + } + } + } + } +} +function buildInputsTable(inputs) { + if (inputs.length === 0) { + return null; + } + var rows = [ + unist.makeTableRow([ + unist.makeTableCell([unist.makeText("Name")]), + unist.makeTableCell([unist.makeText("Type")]), + unist.makeTableCell([unist.makeText("Default value")]), + unist.makeTableCell([unist.makeText("Description")]) + ]) + ]; + for (var i = 0; i < inputs.length; i++) { + var pName = inputs[i].name; + var pType = inputs[i].type; + var pDefault = inputs[i].defaultValue || ""; + var pDesc = inputs[i].description || ""; + if (pDesc) { + pDesc = pDesc.trim().replace(/[\n\r]+/, " "); + } + var cells = [ + unist.makeTableCell([unist.makeText(pName)]), + unist.makeTableCell([unist.makeText(pType)]), + unist.makeTableCell([unist.makeText(pDefault)]), + unist.makeTableCell([unist.makeText(pDesc)]) + ]; + rows.push(unist.makeTableRow(cells)); + } + return unist.makeTable([null, null, null, null], rows); +} +function buildOutputsTable(outputs) { + if (outputs.length === 0) { + return null; + } + var rows = [ + unist.makeTableRow([ + unist.makeTableCell([unist.makeText("Name")]), + unist.makeTableCell([unist.makeText("Type")]), + unist.makeTableCell([unist.makeText("Description")]) + ]) + ]; + for (var i = 0; i < outputs.length; i++) { + var eName = outputs[i].name; + var eType = outputs[i].type; + var eDesc = outputs[i].description || ""; + if (eDesc) { + eDesc = eDesc.trim().replace(/[\n\r]+/, ' '); + } + var cells = [ + unist.makeTableCell([unist.makeText(eName)]), + unist.makeTableCell([unist.makeText(eType)]), + unist.makeTableCell([unist.makeText(eDesc)]) + ]; + rows.push(unist.makeTableRow(cells)); + } + return unist.makeTable([null, null, null], rows); +} +function isNodeExported(node) { + return (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) !== 0 || (!!node.parent && node.parent.kind === ts.SyntaxKind.SourceFile); +} diff --git a/lib/config/DocProcessor/tools/tscProps.ts b/lib/config/DocProcessor/tools/tscProps.ts new file mode 100644 index 0000000000..739b1b5335 --- /dev/null +++ b/lib/config/DocProcessor/tools/tscProps.ts @@ -0,0 +1,237 @@ +import * as ts from "typescript"; +import * as fs from "fs"; +import * as path from "path"; +import * as program from "commander"; + +import * as heading from "mdast-util-heading-range"; + +import * as unist from "../unistHelpers"; + +export function initPhase(aggData) { +} + +export function readPhase(tree, pathname, aggData) { +} + +export function aggPhase(aggData) { +} + +export function updatePhase(tree, pathname, aggData) { + let fileNameNoSuffix = path.basename(pathname, ".md"); + + if (fileNameNoSuffix.match(/component/)) { + let srcData = aggData.srcData[fileNameNoSuffix]; + + if (srcData) { + let srcPath = srcData.path; + let className = fixCompodocFilename(fileNameNoSuffix); + + let inputs = []; + let outputs = []; + getPropDocData(path.resolve(".", srcPath), className, inputs, outputs); + + let inTable = buildInputsTable(inputs); + let outTable = buildOutputsTable(outputs); + + if (inTable) { + console.log("Made a props table"); + heading(tree, "Properties", (before, section, after) => { + return [before, inTable, after]; + }); + } + + if (outTable) { + console.log("Made an events table"); + heading(tree, "Events", (before, section, after) => { + return [before, outTable, after]; + }); + } + } + } +} + + +function initialCap(str: string) { + return str[0].toUpperCase() + str.substr(1); +} + + +function fixCompodocFilename(rawName: string) { + var name = rawName.replace(/\]|\(|\)/g, ''); + + var fileNameSections = name.split('.'); + var compNameSections = fileNameSections[0].split('-'); + + var outCompName = ''; + + for (var i = 0; i < compNameSections.length; i++) { + outCompName = outCompName + initialCap(compNameSections[i]); + } + + var itemTypeIndicator = ''; + + if (fileNameSections.length > 1) { + itemTypeIndicator = initialCap(fileNameSections[1]); + } + + var finalName = outCompName + itemTypeIndicator; + + return finalName; +} + + +function getPropDocData(srcPath: string, docClassName: string, inputs: any[], outputs: any[]) { + let prog = ts.createProgram(program.args, { + target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS + }); + + let sourceFiles = prog.getSourceFiles(); + let checker = prog.getTypeChecker(); + + for (var i = 0; i < sourceFiles.length; i++) { + if (!sourceFiles[i].isDeclarationFile) + ts.forEachChild(sourceFiles[i], visit); + } + + function visit(node: ts.Node) { + if (!isNodeExported(node)) + return; + + if (ts.isClassDeclaration(node) && node.name) { + let classDec: ts.ClassDeclaration = node; + let sourceFile = classDec.getSourceFile(); + + if (classDec.name.escapedText === docClassName) { + getPropDataFromClass(checker, classDec, inputs, outputs); + } + } + } +} + + +function getPropDataFromClass( + checker: ts.TypeChecker, + classDec:ts.ClassDeclaration, + inputs: any[], + outputs: any[] +){ + let sourceFile = classDec.getSourceFile(); + + for (var i = 0; i < classDec.members.length; i++) { + let member = classDec.members[i]; + + if (ts.isPropertyDeclaration(member)) { + let prop: ts.PropertyDeclaration = member; + + let mods = ts.getCombinedModifierFlags(prop); + let nonPrivate = (mods & ts.ModifierFlags.Private) === 0; + let memSymbol = checker.getSymbolAtLocation(prop.name); + + if (nonPrivate && memSymbol && prop.decorators) { + let name = memSymbol.getName(); + let initializer = ""; + + if (prop.initializer) { + initializer = prop.initializer.getText(sourceFile); + } + + let doc = ts.displayPartsToString(memSymbol.getDocumentationComment()); + let propType = checker.typeToString(checker.getTypeOfSymbolAtLocation(memSymbol, memSymbol.valueDeclaration!)); + + let dec = prop.decorators[0].getText(sourceFile); + + if (dec.match(/@Input/)) { + inputs.push({ + "name": name, + "type": propType, + "init": initializer, + "docText": doc + }); + } else if (dec.match(/@Output/)) { + outputs.push({ + "name": name, + "type": propType, + "docText": doc + }); + } + } + } + } +} + + +function buildInputsTable(inputs: any[]) { + if (inputs.length === 0) { + return null; + } + + var rows = [ + unist.makeTableRow([ + unist.makeTableCell([unist.makeText("Name")]), + unist.makeTableCell([unist.makeText("Type")]), + unist.makeTableCell([unist.makeText("Default value")]), + unist.makeTableCell([unist.makeText("Description")]) + ]) + ]; + + for (var i = 0; i < inputs.length; i++) { + var pName = inputs[i].name; + var pType = inputs[i].type; + var pDefault = inputs[i].defaultValue || ""; + var pDesc = inputs[i].description || ""; + + if (pDesc) { + pDesc = pDesc.trim().replace(/[\n\r]+/, " "); + } + + var cells = [ + unist.makeTableCell([unist.makeText(pName)]), + unist.makeTableCell([unist.makeText(pType)]), + unist.makeTableCell([unist.makeText(pDefault)]), + unist.makeTableCell([unist.makeText(pDesc)]) + ]; + + rows.push(unist.makeTableRow(cells)); + } + + return unist.makeTable([null, null, null, null], rows); +} + + +function buildOutputsTable(outputs: any[]) { + if (outputs.length === 0) { + return null; + } + + var rows = [ + unist.makeTableRow([ + unist.makeTableCell([unist.makeText("Name")]), + unist.makeTableCell([unist.makeText("Type")]), + unist.makeTableCell([unist.makeText("Description")]) + ]) + ]; + + for (var i = 0; i < outputs.length; i++){ + var eName = outputs[i].name; + var eType = outputs[i].type; + var eDesc = outputs[i].description || ""; + + if (eDesc) { + eDesc = eDesc.trim().replace(/[\n\r]+/, ' '); + } + + var cells = [ + unist.makeTableCell([unist.makeText(eName)]), + unist.makeTableCell([unist.makeText(eType)]), + unist.makeTableCell([unist.makeText(eDesc)]) + ]; + + rows.push(unist.makeTableRow(cells)); + } + + return unist.makeTable([null, null, null], rows); +} + +function isNodeExported(node: ts.Node): boolean { + return (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) !== 0 || (!!node.parent && node.parent.kind === ts.SyntaxKind.SourceFile); +} \ No newline at end of file diff --git a/lib/config/DocProcessor/unistHelpers.js b/lib/config/DocProcessor/unistHelpers.js new file mode 100644 index 0000000000..c812c51c9d --- /dev/null +++ b/lib/config/DocProcessor/unistHelpers.js @@ -0,0 +1,101 @@ +module.exports = { + + makeRoot: function (children) { + return { + "type": "root", + "children": children + }; + }, + + makeText: function (textVal) { + return { + "type": "text", + "value": textVal + }; + }, + + makeEmphasis: function (content) { + return { + "type": "emphasis", + "children": content + }; + }, + + makeHeading: function (caption, depth) { + return { + "type": "heading", + "depth": depth, + "children": [caption] + }; + }, + + makeLink: function (caption, url) { + return { + "type": "link", + "url": url, + "children": [ caption ] + }; + }, + + makeListItem: function (itemValue) { + return { + "type": "listItem", + "loose": false, + "children": [ itemValue ] + }; + }, + + makeListUnordered: function (itemsArray) { + return { + "type": "list", + "ordered": false, + "children": itemsArray, + "loose": false + }; + }, + + makeParagraph: function (itemsArray) { + return { + "type": "paragraph", + "children": itemsArray + } + }, + + makeTable: function (colAlignArray, rowArray) { + return { + "type": "table", + "align": colAlignArray, + "children": rowArray + }; + }, + + makeTableRow: function (cellArray) { + return { + "type": "tableRow", + "children": cellArray + }; + }, + + makeTableCell: function (content) { + return { + "type": "tableCell", + "children": content + }; + }, + + isHeading: function (node) { + return node.type === "heading"; + }, + + isListUnordered: function (node) { + return (node.type === "list") && !node.ordered; + }, + + isParagraph: function (node) { + return node.type === "paragraph"; + }, + + isText: function (node) { + return node.type === "text"; + } +} \ No newline at end of file