Yuki Takei 7 лет назад
Родитель
Сommit
c89aa1da51

+ 3 - 0
packages/growi-commons/src/plugin/model/tag-context.js

@@ -1,3 +1,6 @@
+/**
+ * Context class for custom-tag-utils#findTagAndReplace
+ */
 class TagContext {
 class TagContext {
 
 
   constructor(initArgs = {}) {
   constructor(initArgs = {}) {

+ 11 - 1
packages/growi-commons/src/plugin/util/args-parser.js

@@ -1,11 +1,21 @@
+/**
+ * Arguments parser for custom tag
+ */
 class ArgsParser {
 class ArgsParser {
 
 
+  /**
+   * @typedef ParseArgsResult
+   * @property {string} firstArgsKey - key of the first argument
+   * @property {string} firstArgsValue - value of the first argument
+   * @property {object} options - key of the first argument
+   */
+
   /**
   /**
    * parse plugin argument strings
    * parse plugin argument strings
    *
    *
    * @static
    * @static
    * @param {string} str
    * @param {string} str
-   * @returns {object} { fistArgsKey: 'key', firstArgsValue: 'val', options: {..} }
+   * @returns {ParseArgsResult}
    */
    */
   static parse(str) {
   static parse(str) {
     let firstArgsKey = null;
     let firstArgsKey = null;

+ 28 - 1
packages/growi-commons/src/plugin/util/custom-tag-utils.js

@@ -1,6 +1,9 @@
 const TagContext = require('../model/tag-context');
 const TagContext = require('../model/tag-context');
 
 
 /**
 /**
+ * @private
+ *
+ * create random strings
  * @see http://qiita.com/ryounagaoka/items/4736c225bdd86a74d59c
  * @see http://qiita.com/ryounagaoka/items/4736c225bdd86a74d59c
  *
  *
  * @param {number} length
  * @param {number} length
@@ -15,11 +18,20 @@ function createRandomStr(length) {
   return generated;
   return generated;
 }
 }
 
 
+/**
+ * @typedef FindTagAndReplaceResult
+ * @property {string} html - HTML string
+ * @property {Object} tagContextMap - Object.<string, [TagContext]{@link ../model/tag-context.html#TagContext}>
+ *
+ * @memberof customTagUtils
+ */
 /**
 /**
  * @param {RegExp} tagPattern
  * @param {RegExp} tagPattern
  * @param {string} html
  * @param {string} html
  * @param {function} replace replace function
  * @param {function} replace replace function
- * @return {{html: string, tagContextMap: Object.<string, TagContext>}}
+ * @return {FindTagAndReplaceResult}
+ *
+ * @memberof customTagUtils
  */
  */
 function findTagAndReplace(tagPattern, html, replace) {
 function findTagAndReplace(tagPattern, html, replace) {
   let replacedHtml = html;
   let replacedHtml = html;
@@ -53,9 +65,24 @@ function findTagAndReplace(tagPattern, html, replace) {
   return { html: replacedHtml, tagContextMap };
   return { html: replacedHtml, tagContextMap };
 }
 }
 
 
+/**
+ * @namespace customTagUtils
+ */
 module.exports = {
 module.exports = {
   findTagAndReplace,
   findTagAndReplace,
+  /**
+   * Context class used by findTagAndReplace
+   * @memberof customTagUtils
+   */
   TagContext,
   TagContext,
+  /**
+   * [ArgsParser]{@link ./args-parser#ArgsParser}
+   * @memberof customTagUtils
+   */
   ArgsParser: require('./args-parser'),
   ArgsParser: require('./args-parser'),
+  /**
+   * [OptionParser]{@link ./option-parser#OptionParser}
+   * @memberof customTagUtils
+   */
   OptionParser: require('./option-parser'),
   OptionParser: require('./option-parser'),
 };
 };

+ 22 - 9
packages/growi-commons/src/plugin/util/option-parser.js

@@ -1,18 +1,31 @@
+/**
+ * Options parser for custom tag
+ */
 class OptionParser {
 class OptionParser {
 
 
   /**
   /**
-   * parse range expression
+   * @typedef ParseRangeResult
+   * @property {number} start - start index
+   * @property {number} end - end index
+   */
+
+  /**
+   * Parse range expression
    *
    *
-   * ex:
-   *  1:2 -> { start: 1, end: 2 }
-   *  1:  -> { start: 1, end: -1 }
-   *  2+3 -> { start: 1, end: 5 }
+   * <ul>
+   *  <li>ex:</li>
+   *  <ul>
+   *    <li>1:2 -> { start: 1, end: 2 }</li>
+   *    <li>1:  -> { start: 1, end: -1 }</li>
+   *    <li>2+3 -> { start: 1, end: 5 }</li>
+   *  </ul>
+   * </ul>
    *
    *
-   * @static
-   * @param {any} str
-   * @returns
+   * @see https://regex101.com/r/w4KCwC/4
    *
    *
-   * @memberOf OptionParser
+   * @static
+   * @param {string} str
+   * @returns {ParseRangeResult}
    */
    */
   static parseRange(str) {
   static parseRange(str) {
     if (str == null) {
     if (str == null) {