@@ -28,6 +28,8 @@ set upload=
2828set licensertf =
2929set lint_js =
3030set lint_cpp =
31+ set lint_md =
32+ set lint_md_build =
3133set build_testgc_addon =
3234set noetw =
3335set noetw_msi_arg =
@@ -53,6 +55,7 @@ set nghttp2_debug=
5355set link_module =
5456set no_cctest =
5557set openssl_no_asm =
58+ set doc =
5659
5760:next-arg
5861if " %1 " == " " goto args-done
@@ -71,7 +74,7 @@ if /i "%1"=="nosnapshot" set nosnapshot=1&goto arg-ok
7174if /i " %1 " == " noetw" set noetw = 1& goto arg-ok
7275if /i " %1 " == " noperfctr" set noperfctr = 1& goto arg-ok
7376if /i " %1 " == " licensertf" set licensertf = 1& goto arg-ok
74- if /i " %1 " == " test" set test_args = %test_args% -J %common_test_suites% & set lint_cpp=1& set lint_js=1& goto arg-ok
77+ if /i " %1 " == " test" set test_args = %test_args% -J %common_test_suites% & set lint_cpp=1& set lint_js=1& set lint_md=1 & goto arg-ok
7578if /i " %1 " == " test-ci" set test_args = %test_args% %test_ci_args% -p tap --logfile test.tap %common_test_suites% & set cctest_args=%cctest_args% --gtest_output=tap:cctest.tap& goto arg-ok
7679if /i " %1 " == " build-addons" set build_addons = 1& goto arg-ok
7780if /i " %1 " == " build-addons-napi" set build_addons_napi = 1& goto arg-ok
@@ -98,7 +101,9 @@ if /i "%1"=="lint-js" set lint_js=1&goto arg-ok
98101if /i " %1 " == " jslint" set lint_js = 1& echo Please use lint-js instead of jslint& goto arg-ok
99102if /i " %1 " == " lint-js-ci" set lint_js_ci = 1& goto arg-ok
100103if /i " %1 " == " jslint-ci" set lint_js_ci = 1& echo Please use lint-js-ci instead of jslint-ci& goto arg-ok
101- if /i " %1 " == " lint" set lint_cpp = 1& set lint_js=1& goto arg-ok
104+ if /i " %1 " == " lint-md" set lint_md = 1& goto arg-ok
105+ if /i " %1 " == " lint-md-build" set lint_md_build = 1& goto arg-ok
106+ if /i " %1 " == " lint" set lint_cpp = 1& set lint_js=1& set lint_md=1& goto arg-ok
102107if /i " %1 " == " lint-ci" set lint_cpp = 1& set lint_js_ci=1& goto arg-ok
103108if /i " %1 " == " package" set package = 1& goto arg-ok
104109if /i " %1 " == " msi" set msi = 1& set licensertf=1& set download_arg=" --download=all" & set i18n_arg=small-icu& goto arg-ok
@@ -118,6 +123,7 @@ if /i "%1"=="debug-nghttp2" set debug_nghttp2=1&goto arg-ok
118123if /i " %1 " == " link-module" set " link_module = --link-module=%2 %link_module% " & goto arg-ok-2
119124if /i " %1 " == " no-cctest" set no_cctest = 1& goto arg-ok
120125if /i " %1 " == " openssl-no-asm" set openssl_no_asm = 1& goto arg-ok
126+ if /i " %1 " == " doc" set doc = 1& goto arg-ok
121127
122128echo Error: invalid command line option `%1 `.
123129exit /b 1
@@ -146,6 +152,7 @@ if defined build_release (
146152:: assign path to node_exe
147153set " node_exe = %config% \node.exe"
148154set " node_gyp_exe = " %node_exe% " deps\npm\node_modules\node-gyp\bin\node-gyp"
155+ set " npm_exe = " %~dp0 %node_exe% " %~dp0 deps\npm\bin\npm-cli.js"
149156if " %target_env% " == " vs2017" set " node_gyp_exe = %node_gyp_exe% --msvs_version=2017"
150157
151158if " %config% " == " Debug" set configure_flags = %configure_flags% --debug
@@ -179,7 +186,11 @@ call :getnodeversion || exit /b 1
179186
180187if defined TAG set configure_flags = %configure_flags% --tag=%TAG%
181188
182- if " %target% " == " Clean" rmdir /Q /S " %~dp0 %config% \node-v%FULLVERSION% -win-%target_arch% " > nul 2 > nul
189+ if not " %target% " == " Clean" goto skip-clean
190+ rmdir /Q /S " %~dp0 %config% \node-v%FULLVERSION% -win-%target_arch% " > nul 2 > nul
191+ rmdir /Q /S " %~dp0 tools\remark-cli\node_modules"
192+ rmdir /Q /S " %~dp0 tools\remark-preset-lint-node\node_modules"
193+ :skip-clean
183194
184195if defined noprojgen if defined nobuild if not defined sign if not defined msi goto licensertf
185196
@@ -235,7 +246,7 @@ goto exit
235246
236247:wix-not-found
237248echo Build skipped. To generate installer, you need to install Wix.
238- goto run
249+ goto build-doc
239250
240251:msbuild-found
241252
@@ -342,7 +353,7 @@ exit /b 1
342353
343354:msi
344355@ rem Skip msi generation if not requested
345- if not defined msi goto run
356+ if not defined msi goto build-doc
346357
347358:msibuild
348359echo Building node-v%FULLVERSION% -%target_arch% .msi
@@ -357,7 +368,7 @@ if errorlevel 1 echo Failed to sign msi&goto exit
357368
358369:upload
359370@ rem Skip upload if not requested
360- if not defined upload goto run
371+ if not defined upload goto build-doc
361372
362373if not defined SSHCONFIG (
363374 echo SSHCONFIG is not set for upload
@@ -385,6 +396,30 @@ ssh -F %SSHCONFIG% %STAGINGSERVER% "touch nodejs/%DISTTYPEDIR%/v%FULLVERSION%/no
385396if errorlevel 1 goto exit
386397
387398
399+ :build-doc
400+ @ rem Build documentation if requested
401+ if not defined doc goto run
402+ if not exist %node_exe% (
403+ echo Failed to find node.exe
404+ goto run
405+ )
406+ mkdir %config% \doc
407+ robocopy /e doc\api %config% \doc\api
408+ robocopy /e doc\api_assets %config% \doc\api\assets
409+
410+ if exist " tools\doc\node_modules\js-yaml\package.json" goto doc-skip-js-yaml
411+ SETLOCAL
412+ cd tools\doc
413+ %npm_exe% install
414+ cd ..\..
415+ if errorlevel 1 goto exit
416+ ENDLOCAL
417+ :doc-skip-js-yaml
418+ for %%F in (%config% \doc\api\*.md) do (
419+ %node_exe% tools\doc\generate.js --format=json %%F > %%~dF%%~pF%%~nF .json
420+ %node_exe% tools\doc\generate.js --node-version=v%FULLVERSION% --format=html --analytics=%DOCS_ANALYTICS% %%F > %%~dF%%~pF%%~nF .html
421+ )
422+
388423:run
389424@ rem Run tests if requested.
390425
@@ -528,28 +563,73 @@ goto exit
528563
529564:lint-js
530565if defined lint_js_ci goto lint-js-ci
531- if not defined lint_js goto exit
566+ if not defined lint_js goto lint-md-build
532567if not exist tools\node_modules\eslint goto no-lint
533568echo running lint-js
534569%config% \node tools\node_modules\eslint\bin\eslint.js --cache --rule " linebreak-style: 0" --ext=.js,.mjs,.md .eslintrc.js benchmark doc lib test tools
535- goto exit
570+ goto lint-md-build
536571
537572:lint-js-ci
538573echo running lint-js-ci
539574%config% \node tools\lint-js.js -J -f tap -o test-eslint.tap benchmark doc lib test tools
540- goto exit
575+ goto lint-md-build
541576
542577:no-lint
543578echo Linting is not available through the source tarball.
544579echo Use the git repo instead: $ git clone https://github.com/nodejs/node.git
580+ goto lint-md-build
581+
582+ :lint-md-build
583+ if not defined lint_md_build goto lint-md
584+ SETLOCAL
585+ echo Markdown linter: installing remark-cli into tools\
586+ cd tools\remark-cli
587+ %npm_exe% install
588+ cd ..\..
589+ if errorlevel 1 goto lint-md-build-failed
590+ echo Markdown linter: installing remark-preset-lint-node into tools\
591+ cd tools\remark-preset-lint-node
592+ %npm_exe% install
593+ cd ..\..
594+ if errorlevel 1 goto lint-md-build-failed
595+ ENDLOCAL
596+ goto lint-md
597+
598+ :if errorlevel 1 goto lint-md-build-failed
599+ ENDLOCAL
600+ echo Failed to install markdown linter
601+ exit /b 1
602+
603+ :lint-md
604+ if not defined lint_md goto exit
605+ if not exist tools\remark-cli\node_modules goto lint-md-no-tools
606+ if not exist tools\remark-preset-lint-node\node_modules goto lint-md-no-tools
607+ echo Running Markdown linter on docs...
608+ SETLOCAL ENABLEDELAYEDEXPANSION
609+ set lint_md_files =
610+ cd doc
611+ for /D %%D IN (*) do (
612+ for %%F IN (%%D \*.md) do (
613+ set " lint_md_files = " doc\%%F " !lint_md_files! "
614+ )
615+ )
616+ cd ..
617+ %config% \node tools\remark-cli\cli.js -q -f %lint_md_files%
618+ ENDLOCAL
545619goto exit
546620
621+ :lint-md-no-tools
622+ echo The markdown linter is not installed.
623+ echo To install (requires internet access) run: vcbuild lint-md-build
624+ goto exit
625+
626+
547627:create-msvs-files-failed
548628echo Failed to create vc project files.
549629goto exit
550630
551631:help
552- echo vcbuild.bat [debug/release] [msi] [test/test-ci/test-all/test-addons/test-addons-napi/test-internet/test-pummel/test-simple/test-message/test-gc/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm]
632+ echo vcbuild.bat [debug/release] [msi] [doc] [ test/test-ci/test-all/test-addons/test-addons-napi/test-internet/test-pummel/test-simple/test-message/test-gc/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci/lint-md] [lint-md-build ] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm]
553633echo Examples:
554634echo vcbuild.bat : builds release build
555635echo vcbuild.bat debug : builds debug build
@@ -558,7 +638,7 @@ echo vcbuild.bat test : builds debug build and runs tests
558638echo vcbuild.bat build-release : builds the release distribution as used by nodejs.org
559639echo vcbuild.bat enable-vtune : builds nodejs with Intel VTune profiling support to profile JavaScript
560640echo vcbuild.bat link-module my_module.js : bundles my_module as built-in module
561- echo vcbuild.bat lint : runs the C++ and JavaScript linter
641+ echo vcbuild.bat lint : runs the C++, documentation and JavaScript linter
562642echo vcbuild.bat no-cctest : skip building cctest.exe
563643goto exit
564644
0 commit comments