Skip to content

Commit

Permalink
Fix: Fixed building documentation on Windows. Closes #7212.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Nov 5, 2020
2 parents bb9adfd + b769fbb commit c7f69dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"svgo": "^1.3.2",
"terser-webpack-plugin": "^3.0.2",
"umberto": "^1.5.4",
"upath": "^2.0.0",
"webpack": "^4.43.0"
},
"engines": {
Expand Down
17 changes: 8 additions & 9 deletions scripts/docs/buildapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@

'use strict';

const path = require( 'path' );

module.exports = function buildApiDocs() {
const ckeditor5Docs = require( '@ckeditor/ckeditor5-dev-docs' );

return ckeditor5Docs
.build( {
readmePath: path.join( process.cwd(), 'README.md' ),
// Patterns that do not start with '/' are mounted onto process.cwd() path by default.
readmePath: 'README.md',
sourceFiles: [
process.cwd() + '/packages/@(ckeditor|ckeditor5)-*/src/**/*.@(js|jsdoc)',
'!' + process.cwd() + '/packages/@(ckeditor|ckeditor5)-*/src/lib/**/*.js',
'!' + process.cwd() + '/packages/ckeditor5-build-*/src/**/*.js',
process.cwd() + '/external/*/packages/@(ckeditor|ckeditor5)-*/src/**/*.@(js|jsdoc)',
'!' + process.cwd() + '/external/*/packages/@(ckeditor|ckeditor5)-*/src/lib/**/*.js',
'!' + process.cwd() + '/external/*/packages/ckeditor5-build-*/src/**/*.js'
'packages/@(ckeditor|ckeditor5)-*/src/**/*.@(js|jsdoc)',
'!packages/@(ckeditor|ckeditor5)-*/src/lib/**/*.js',
'!packages/ckeditor5-build-*/src/**/*.js',
'external/*/packages/@(ckeditor|ckeditor5)-*/src/**/*.@(js|jsdoc)',
'!external/*/packages/@(ckeditor|ckeditor5)-*/src/lib/**/*.js',
'!external/*/packages/ckeditor5-build-*/src/**/*.js'
],
validateOnly: process.argv.includes( '--validate-only' ),
strict: process.argv.includes( '--strict' )
Expand Down
12 changes: 8 additions & 4 deletions scripts/docs/snippetadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/* eslint-env node */

const path = require( 'path' );
const upath = require( 'upath' );
const fs = require( 'fs' );
const minimatch = require( 'minimatch' );
const webpack = require( 'webpack' );
Expand Down Expand Up @@ -282,7 +283,7 @@ function getConstantDefinitions( snippets ) {
knownPaths.add( directory );

const absolutePathToConstants = path.join( directory, 'docs', 'constants.js' );
const importPathToConstants = path.posix.relative( __dirname, absolutePathToConstants );
const importPathToConstants = path.relative( __dirname, absolutePathToConstants );

if ( fs.existsSync( absolutePathToConstants ) ) {
const packageConstantDefinitions = require( './' + importPathToConstants );
Expand Down Expand Up @@ -432,7 +433,7 @@ function getWebpackConfig( snippets, config ) {

for ( const snippetData of snippets ) {
if ( !webpackConfig.output.path ) {
webpackConfig.output.path = snippetData.outputPath;
webpackConfig.output.path = path.normalize( snippetData.outputPath );
}

if ( webpackConfig.entry[ snippetData.snippetName ] ) {
Expand Down Expand Up @@ -490,7 +491,8 @@ function getPackageDependenciesPaths() {
};

return glob.sync( 'packages/*/node_modules', globOptions )
.concat( glob.sync( 'external/*/packages/*/node_modules', globOptions ) );
.concat( glob.sync( 'external/*/packages/*/node_modules', globOptions ) )
.map( p => path.normalize( p ) );
}

/**
Expand All @@ -512,14 +514,16 @@ function readSnippetConfig( snippetSourcePath ) {
}

/**
* Removes duplicated entries specified in `files` array and map those entires using `mapFunction`.
* Removes duplicated entries specified in `files` array, unifies path separators to always be `/`
* and then maps those entries using `mapFunction`.
*
* @param {Array.<String>} files Paths collection.
* @param {Function} mapFunction Function that should return a string.
* @returns {String}
*/
function getHTMLImports( files, mapFunction ) {
return [ ...new Set( files ) ]
.map( path => upath.normalize( path ) )
.map( mapFunction )
.join( '\n' )
.replace( /^\s+/, '' );
Expand Down

0 comments on commit c7f69dd

Please sign in to comment.