Browse Source

Merge pull request #5697 from wenzhixin/fix/5693

Fix/5693
文翼 4 years ago
parent
commit
6e9c146b06
2 changed files with 13 additions and 3 deletions
  1. 3 3
      site/docs/api/table-options.md
  2. 10 0
      tools/check-api.js

+ 3 - 3
site/docs/api/table-options.md

@@ -1296,7 +1296,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 ## showButtonIcons
 
-- **Attribute:** `show-button-icons`
+- **Attribute:** `data-show-button-icons`
 
 - **Type:** `Boolean`
 
@@ -1310,7 +1310,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 ## showButtonText
 
-- **Attribute:** `show-button-text`
+- **Attribute:** `data-show-button-text`
 
 - **Type:** `Boolean`
 
@@ -1842,7 +1842,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 ## visibleSearch
 
-- **Attribute:** `visible-search`
+- **Attribute:** `data-visible-search`
 
 - **Type:** `Boolean`
 

+ 10 - 0
tools/check-api.js

@@ -7,6 +7,7 @@ let errorSum = 0
 const exampleFilesFolder = './bootstrap-table-examples/'
 const exampleFilesFound = fs.existsSync(exampleFilesFolder)
 let exampleFiles = []
+
 if (exampleFilesFound) {
   exampleFiles = [
     ...fs.readdirSync(exampleFilesFolder + 'welcomes'),
@@ -38,6 +39,7 @@ class API {
     const outLines = lines.slice(0, 1)
     const errors = []
     const exampleRegex = /\[.*\]\(.*\/(.*\.html)\)/m
+    const attributeRegex = /\*\*Attribute:\*\*\s`(.*)data-(.*)`/m
 
     for (const item of lines.slice(1)) {
       md[item.split('\n')[0]] = item
@@ -52,6 +54,7 @@ class API {
 
           for (let i = 0; i < this.attributes.length; i++) {
             const name = this.attributes[i]
+
             if (this.ignore && this.ignore[key] && this.ignore[key].includes(name)) {
               continue
             }
@@ -67,6 +70,13 @@ class API {
               if (!exampleFiles.includes(matches[1])) {
                 errors.push(chalk.red(`[${key}] example '${matches[1]}' could not be found`))
               }
+            } else if (name === 'Attribute' && key !== 'columns') {
+              const attributeMatches = attributeRegex.exec(tmpDetails)
+
+              if (!attributeMatches) {
+                errors.push(chalk.red(`[${key}] missing or wrong formatted attribute`, `"${tmpDetails}"`))
+                continue
+              }
             }
 
             if (!tmpDetails || tmpDetails.indexOf(`**${name}:**`) === -1) {