mirror of
				https://github.com/mdbootstrap/mdb-ui-kit.git
				synced 2025-10-31 16:07:53 +03:00 
			
		
		
		
	separate main and docs gulp files for easier maintenance
This commit is contained in:
		
							parent
							
								
									0dd3573840
								
							
						
					
					
						commit
						2dafee14dc
					
				
							
								
								
									
										129
									
								
								gulp-docs.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								gulp-docs.js
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,129 @@ | ||||||
|  | import {Preset, Clean, Copy, Jekyll, MinifyCss, Sass, RollupEs, RollupUmd, RollupIife, ScssLint, EsLint, TaskSeries, Uglify} from 'gulp-pipeline/src/index' | ||||||
|  | //import gulp from 'gulp'
 | ||||||
|  | //import findup from 'findup-sync'
 | ||||||
|  | //import pkg from './package.json'
 | ||||||
|  | //import moment from 'moment'
 | ||||||
|  | 
 | ||||||
|  | const referenceDocNotice = | ||||||
|  |   `$1\n | ||||||
|  | [//]: # DO NOT EDIT IT WILL BE OVERWRITTEN - copy of bootstrap documentation generated by gulp docs:copy:bs\n
 | ||||||
|  | {% callout info %}\n**Bootstrap Reference Documentation** | ||||||
|  | This is a part of the reference documentation from <a href="http://getbootstrap.com">Bootstrap</a>. | ||||||
|  | It is included here to demonstrate rendering with Material Design for Bootstrap default styling. | ||||||
|  | See the <a href="/material-design/buttons">Material Design</a> section for more elements and customization options. | ||||||
|  | {% endcallout %} | ||||||
|  | \n\n$2` | ||||||
|  | 
 | ||||||
|  | const copyProcessor = (content, srcpath) => { // https://regex101.com/r/cZ7aO8/2
 | ||||||
|  |   return content | ||||||
|  |     .replace(/(---[\s\S]+?---)([\s\S]+)/mg, referenceDocNotice) // insert docs reference
 | ||||||
|  |     .replace(/Fancy display heading/, 'Fancy heading')          // remove sample text 'display' as this is a particular MD style and is confusing
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | const preset = Preset.baseline({ | ||||||
|  |   javascripts: { | ||||||
|  |     source: {options: {cwd: 'docs/assets/js/src'}}, | ||||||
|  |     watch: {options: {cwd: 'docs/assets/js/src'}}, | ||||||
|  |     test: {options: {cwd: 'docs/assets/js/tests'}}, | ||||||
|  |     dest: 'docs/dist' | ||||||
|  |   }, | ||||||
|  |   stylesheets: { | ||||||
|  |     source: {options: {cwd: 'docs/assets/scss'}}, | ||||||
|  |     watch: {options: {cwd: 'docs/assets/scss'}}, | ||||||
|  |     dest: 'docs/dist' | ||||||
|  |   } | ||||||
|  | }) | ||||||
|  | 
 | ||||||
|  | const prefix = {task: {prefix: 'docs:'}} | ||||||
|  | 
 | ||||||
|  | export default function (gulp, options) { | ||||||
|  | 
 | ||||||
|  |   let javascripts = [ | ||||||
|  |     new RollupIife(gulp, preset, prefix, options.rollupConfig, { | ||||||
|  |     options: { | ||||||
|  |       dest: 'docs.iife.js', | ||||||
|  |       moduleName: 'docs' | ||||||
|  |     } | ||||||
|  |   }), | ||||||
|  |     new Uglify(gulp, preset, prefix, { | ||||||
|  |       task: {name: 'vendor:uglify'}, | ||||||
|  |       source: {options: {cwd: 'docs/assets/js/vendor'}}, | ||||||
|  |       options: {dest: 'docs-vendor.min.js'} | ||||||
|  |     }) | ||||||
|  |   ] | ||||||
|  | 
 | ||||||
|  |   let eslint = new EsLint(gulp, preset, prefix) | ||||||
|  |   let scsslint = new ScssLint(gulp, preset, prefix, { | ||||||
|  |     source: {glob: ['**/*.scss', '!docs.scss']}, | ||||||
|  |     watch: {glob: ['**/*.scss', '!docs.scss']} | ||||||
|  |   }) | ||||||
|  |   let linters = [scsslint, eslint] | ||||||
|  |   let sass = new Sass(gulp, preset, prefix) | ||||||
|  |   let jekyll = new Jekyll(gulp, preset, prefix, {options: {raw: 'baseurl: "/bootstrap-material-design"'}}) | ||||||
|  | 
 | ||||||
|  |   new TaskSeries(gulp, 'default', [ | ||||||
|  |     new Clean(gulp, preset), | ||||||
|  |     linters, | ||||||
|  |     [ | ||||||
|  |       sass, | ||||||
|  |       javascripts | ||||||
|  |     ], | ||||||
|  |     new MinifyCss(gulp, preset, prefix) | ||||||
|  |   ], prefix) | ||||||
|  |   new TaskSeries(gulp, 'lint', linters, prefix) | ||||||
|  |   new TaskSeries(gulp, 'js', [eslint, javascripts], prefix) | ||||||
|  |   new TaskSeries(gulp, 'css', [scsslint, sass], prefix) | ||||||
|  | 
 | ||||||
|  |   // docs copy
 | ||||||
|  |   new TaskSeries(gulp, 'copy:bs-docs', [ | ||||||
|  |     new Copy(gulp, preset, prefix, { | ||||||
|  |       task: {name: 'copy:bs-docs-content'}, | ||||||
|  |       source: { | ||||||
|  |         options: {cwd: '../bootstrap/docs/content'}, | ||||||
|  |         glob: ['**/*'] | ||||||
|  |       }, | ||||||
|  |       dest: 'docs/content/', | ||||||
|  |       process: copyProcessor | ||||||
|  |     }), | ||||||
|  |     new Copy(gulp, preset, prefix, { | ||||||
|  |       task: {name: 'copy:bs-docs-components'}, | ||||||
|  |       source: { | ||||||
|  |         options: {cwd: '../bootstrap/docs/components'}, | ||||||
|  |         glob: ['**/*'] | ||||||
|  |       }, | ||||||
|  |       dest: 'docs/components/', | ||||||
|  |       process: copyProcessor | ||||||
|  |     }), | ||||||
|  |     new Copy(gulp, preset, prefix, { | ||||||
|  |       task: {name: 'copy:bs-docs-scss'}, | ||||||
|  |       source: { | ||||||
|  |         options: {cwd: '../bootstrap/docs/assets/scss'}, | ||||||
|  |         glob: ['**/*', '!docs.scss'] // keep variable customizations
 | ||||||
|  |       }, | ||||||
|  |       dest: 'docs/assets/scss/', | ||||||
|  |       process: (content, srcpath) => { | ||||||
|  |         return content.replace(/([\s\S]+)/mg, '// DO NOT EDIT IT WILL BE OVERWRITTEN - copy of bootstrap documentation generated by gulp docs:copy:bs\n\n$1'); | ||||||
|  |       } | ||||||
|  |     }), | ||||||
|  |     new Copy(gulp, preset, prefix, { | ||||||
|  |       task: {name: 'copy:bs-docs-plugins'}, | ||||||
|  |       source: { | ||||||
|  |         options: {cwd: '../bootstrap/docs/_plugins'}, | ||||||
|  |         glob: ['**/*', '!bridge.rb'] | ||||||
|  |       }, | ||||||
|  |       dest: 'docs/_plugins/' | ||||||
|  |     }), | ||||||
|  |     new Copy(gulp, preset, prefix, { | ||||||
|  |       task: {name: 'copy:bs-docs-js-vendor'}, | ||||||
|  |       source: { | ||||||
|  |         options: {cwd: '../bootstrap/docs/assets/js/vendor'}, | ||||||
|  |         glob: [ | ||||||
|  |           '**/*', | ||||||
|  |           '!tether.min.js', | ||||||
|  |           '!jquery.min.js' | ||||||
|  |         ] | ||||||
|  |       }, | ||||||
|  |       dest: 'docs/assets/js/vendor/' | ||||||
|  |     }, prefix) | ||||||
|  |   ]) | ||||||
|  | } | ||||||
|  | @ -1,17 +1,11 @@ | ||||||
| import {Preset, Clean, Copy, Jekyll, MinifyCss, Sass, RollupEs, RollupUmd, RollupIife, ScssLint, EsLint, TaskSeries, Uglify} from 'gulp-pipeline/src/index' | import {Preset, Clean, Copy, Jekyll, MinifyCss, Sass, RollupEs, RollupUmd, RollupIife, ScssLint, EsLint, TaskSeries, Uglify} from 'gulp-pipeline/src/index' | ||||||
| 
 |  | ||||||
| // debug the project source - remove for repo
 |  | ||||||
| //import {Clean, CleanDigest, Images, MinifyCss, Sass, RollupIife, ScssLint, EsLint, Rev, TaskSeries} from 'gulp-pipeline'
 |  | ||||||
| //import Preset from '../../../gulp-pipeline/src/preset'
 |  | ||||||
| import extend from 'extend' |  | ||||||
| 
 |  | ||||||
| import stringify from 'stringify-object' |  | ||||||
| import gulp from 'gulp' | import gulp from 'gulp' | ||||||
| import findup from 'findup-sync' | import findup from 'findup-sync' | ||||||
| const node_modules = findup('node_modules') |  | ||||||
| import pkg from './package.json' | import pkg from './package.json' | ||||||
| import moment from 'moment' | import moment from 'moment' | ||||||
|  | import gulpDocs from './gulp-docs' | ||||||
| 
 | 
 | ||||||
|  | const node_modules = findup('node_modules') | ||||||
| 
 | 
 | ||||||
| let preset = Preset.baseline({ | let preset = Preset.baseline({ | ||||||
|   javascripts: { |   javascripts: { | ||||||
|  | @ -60,163 +54,51 @@ let rollupConfig = { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| let rollups = [ | let rollups = [ | ||||||
|   new RollupEs(gulp, preset, extend(true, {}, rollupConfig, {options: {dest: 'bootstrap-material-design.es.js'}})), |   new RollupEs(gulp, preset, rollupConfig, {options: {dest: 'bootstrap-material-design.es.js'}}), | ||||||
|   new RollupUmd(gulp, preset, extend(true, {}, rollupConfig, { |   new RollupUmd(gulp, preset, rollupConfig, { | ||||||
|     options: { |     options: { | ||||||
|       dest: 'bootstrap-material-design.umd.js', |       dest: 'bootstrap-material-design.umd.js', | ||||||
|       moduleName: 'bootstrapMaterialDesign' |       moduleName: 'bootstrapMaterialDesign' | ||||||
|     } |     } | ||||||
|   })), |   }), | ||||||
|   new RollupIife(gulp, preset, extend(true, {}, rollupConfig, { |   new RollupIife(gulp, preset, rollupConfig, { | ||||||
|     options: { |     options: { | ||||||
|       dest: 'bootstrap-material-design.iife.js', |       dest: 'bootstrap-material-design.iife.js', | ||||||
|       moduleName: 'bootstrapMaterialDesign' |       moduleName: 'bootstrapMaterialDesign' | ||||||
|     } |     } | ||||||
|   })), |   }), | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| let eslint = new EsLint(gulp, preset) | let eslint = new EsLint(gulp, preset) | ||||||
| let scsslint = new ScssLint(gulp, preset) | let scsslint = new ScssLint(gulp, preset) | ||||||
| let sass = new Sass(gulp, preset) | let sass = new Sass(gulp, preset) | ||||||
| let lint = [scsslint, eslint] | let linters = [scsslint, eslint] | ||||||
| 
 | 
 | ||||||
| // instantiate ordered array of recipes (for each instantiation the tasks will be created e.g. sass and sass:watch)
 | new TaskSeries(gulp, 'default', [ | ||||||
| let recipes = [ |  | ||||||
|   new Clean(gulp, preset), |   new Clean(gulp, preset), | ||||||
|   lint, |   linters, | ||||||
|   [ |   [ | ||||||
|     sass, |     sass, | ||||||
|     rollups |     rollups | ||||||
|   ], |   ], | ||||||
|   new MinifyCss(gulp, preset) |   new MinifyCss(gulp, preset) | ||||||
| ] | ]) | ||||||
| 
 | new TaskSeries(gulp, 'lint', linters) | ||||||
| // Simple helper to create the default and watch tasks as a sequence of the recipes already defined
 |  | ||||||
| new TaskSeries(gulp, 'default', recipes) |  | ||||||
| new TaskSeries(gulp, 'lint', lint) |  | ||||||
| new TaskSeries(gulp, 'js', [eslint, rollups]) | new TaskSeries(gulp, 'js', [eslint, rollups]) | ||||||
| new TaskSeries(gulp, 'css', [scsslint, sass]) | new TaskSeries(gulp, 'css', [scsslint, sass]) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /** | gulpDocs(gulp, {rollupConfig: rollupConfig}) | ||||||
|  * DOCS |  | ||||||
|  */ |  | ||||||
| let docsPreset = Preset.baseline({ |  | ||||||
|   javascripts: { |  | ||||||
|     source: {options: {cwd: 'docs/assets/js/src'}}, |  | ||||||
|     watch: {options: {cwd: 'docs/assets/js/src'}}, |  | ||||||
|     test: {options: {cwd: 'docs/assets/js/tests'}}, |  | ||||||
|     dest: 'docs/dist' |  | ||||||
|   }, |  | ||||||
|   stylesheets: { |  | ||||||
|     source: {options: {cwd: 'docs/assets/scss'}}, |  | ||||||
|     watch: {options: {cwd: 'docs/assets/scss'}}, |  | ||||||
|     dest: 'docs/dist' |  | ||||||
|   } |  | ||||||
| }) |  | ||||||
| 
 | 
 | ||||||
| const docsConfig = {task: {prefix: 'docs:'}} |  | ||||||
| 
 | 
 | ||||||
| let docs = [ | //
 | ||||||
|   [ | //new Copy(gulp, preset, {
 | ||||||
|     new ScssLint(gulp, docsPreset, docsConfig, { | //  task: {name: 'copy:dist-to-docs'},
 | ||||||
|       source: {glob: ['**/*.scss', '!docs.scss']}, | //  source: {
 | ||||||
|       watch: {glob: ['**/*.scss', '!docs.scss']} | //    options: {cwd: 'dist'},
 | ||||||
|     }), | //    glob: ['js/*.iife*', 'css/*.*']
 | ||||||
|     new EsLint(gulp, docsPreset, docsConfig) | //  },
 | ||||||
|   ], | //  dest: 'docs/dist/'
 | ||||||
|   [ | //})
 | ||||||
|     new RollupIife(gulp, docsPreset, docsConfig, rollupConfig, { | //
 | ||||||
|       options: { | //new TaskSeries(gulp, 'prep-release', [])
 | ||||||
|         dest: 'docs.iife.js', |  | ||||||
|         moduleName: 'docs' |  | ||||||
|       } |  | ||||||
|     }), |  | ||||||
|     new Uglify(gulp, docsPreset, docsConfig, { |  | ||||||
|       task: {name: 'vendor:uglify'}, |  | ||||||
|       source: {options: {cwd: 'docs/assets/js/vendor'}}, |  | ||||||
|       options: {dest: 'docs-vendor.min.js'} |  | ||||||
|     }), |  | ||||||
|     new Sass(gulp, docsPreset, docsConfig) |  | ||||||
|   ] |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| const referenceDocNotice = |  | ||||||
|   `$1\n |  | ||||||
| [//]: # DO NOT EDIT IT WILL BE OVERWRITTEN - copy of bootstrap documentation generated by gulp docs:copy:bs\n
 |  | ||||||
| {% callout info %}\n**Bootstrap Reference Documentation** |  | ||||||
| This is a part of the reference documentation from <a href="http://getbootstrap.com">Bootstrap</a>. |  | ||||||
| It is included here to demonstrate rendering with Material Design for Bootstrap default styling. |  | ||||||
| See the <a href="/material-design/buttons">Material Design</a> section for more elements and customization options. |  | ||||||
| {% endcallout %} |  | ||||||
| \n\n$2` |  | ||||||
| 
 |  | ||||||
| const docsProcess = (content, srcpath) => { // https://regex101.com/r/cZ7aO8/2
 |  | ||||||
|   return content |  | ||||||
|     .replace(/(---[\s\S]+?---)([\s\S]+)/mg, referenceDocNotice) // insert docs reference
 |  | ||||||
|     .replace(/Fancy display heading/, 'Fancy heading')          // remove sample text 'display' as this is a particular MD style and is confusing
 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| let bsDocs = [ |  | ||||||
|   new Copy(gulp, docsPreset, docsConfig, { |  | ||||||
|     task: {name: 'copy:bs-docs-content'}, |  | ||||||
|     source: { |  | ||||||
|       options: {cwd: '../bootstrap/docs/content'}, |  | ||||||
|       glob: ['**/*'] |  | ||||||
|     }, |  | ||||||
|     dest: 'docs/content/', |  | ||||||
|     process: docsProcess |  | ||||||
|   }), |  | ||||||
|   new Copy(gulp, docsPreset, docsConfig, { |  | ||||||
|     task: {name: 'copy:bs-docs-components'}, |  | ||||||
|     source: { |  | ||||||
|       options: {cwd: '../bootstrap/docs/components'}, |  | ||||||
|       glob: ['**/*'] |  | ||||||
|     }, |  | ||||||
|     dest: 'docs/components/', |  | ||||||
|     process: docsProcess |  | ||||||
|   }), |  | ||||||
|   new Copy(gulp, docsPreset, docsConfig, { |  | ||||||
|     task: {name: 'copy:bs-docs-scss'}, |  | ||||||
|     source: { |  | ||||||
|       options: {cwd: '../bootstrap/docs/assets/scss'}, |  | ||||||
|       glob: ['**/*', '!docs.scss'] // keep variable customizations
 |  | ||||||
|     }, |  | ||||||
|     dest: 'docs/assets/scss/', |  | ||||||
|     process: (content, srcpath) => { |  | ||||||
|       return content.replace(/([\s\S]+)/mg, '// DO NOT EDIT IT WILL BE OVERWRITTEN - copy of bootstrap documentation generated by gulp docs:copy:bs\n\n$1'); |  | ||||||
|     } |  | ||||||
|   }), |  | ||||||
|   new Copy(gulp, docsPreset, docsConfig, { |  | ||||||
|     task: {name: 'copy:bs-docs-plugins'}, |  | ||||||
|     source: { |  | ||||||
|       options: {cwd: '../bootstrap/docs/_plugins'}, |  | ||||||
|       glob: ['**/*', '!bridge.rb'] |  | ||||||
|     }, |  | ||||||
|     dest: 'docs/_plugins/' |  | ||||||
|   }), |  | ||||||
|   new Copy(gulp, docsPreset, docsConfig, { |  | ||||||
|     task: {name: 'copy:bs-docs-js-vendor'}, |  | ||||||
|     source: { |  | ||||||
|       options: {cwd: '../bootstrap/docs/assets/js/vendor'}, |  | ||||||
|       glob: [ |  | ||||||
|         '**/*', |  | ||||||
|         '!tether.min.js', |  | ||||||
|         '!jquery.min.js' |  | ||||||
|       ] |  | ||||||
|     }, |  | ||||||
|     dest: 'docs/assets/js/vendor/' |  | ||||||
|   }) |  | ||||||
| ] |  | ||||||
| new TaskSeries(gulp, 'docs:copy:bs', bsDocs) |  | ||||||
| 
 |  | ||||||
| new Copy(gulp, docsPreset, docsConfig, { |  | ||||||
|   task: {name: 'copy:dist'}, |  | ||||||
|   source: { |  | ||||||
|     options: {cwd: 'dist'}, |  | ||||||
|     glob: ['js/*.iife*', 'css/*.*'] |  | ||||||
|   }, |  | ||||||
|   dest: 'docs/dist/' |  | ||||||
| }) |  | ||||||
| 
 |  | ||||||
| new Jekyll(gulp, docsPreset, docsConfig, {options: {raw: 'baseurl: "/bootstrap-material-design"'}}) |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user