Skip to content

Commit f9a74f8

Browse files
committed
feat: add option to disable completely title formatting
1 parent 942fad0 commit f9a74f8

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

bin/summary.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ program
2727
.option("-u, --unchanged [list]", "unchanged catalog like `request.js`, default is `[]`.")
2828
.option("-o, --outputfile [string]", "output file, defaut is `./SUMMARY.md`")
2929
.option("-s, --sortedBy [string]", "sorted by sortedBy, for example: `num-`, defaut is sorted by characters")
30+
.option("-d, --disableTitleFormatting", "don't convert filename/folder name to start case (for example: `JavaScript` to `Java Script`), default is `false`")
3031
.action(function(options) {
3132
// generate `SUMMARY.md`
32-
// Fixme
33+
// Fixme
3334
// if (options.length >= 1) {
3435
// console.log(color.red('\nError! The sub commands "%s" has been deprecated, please read the follow messages:'), cmd);
3536
// program.help();

lib/bookJson.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function BookConfig(root) {
1919
book.unchanged = config.unchanged || [];
2020
book.bookname = config.bookname || 'Your Book Name';
2121
book.sortedBy = config.sortedBy || '';
22-
22+
book.disableTitleFormatting = config.disableTitleFormatting || false;
23+
2324
return book;
2425
}
2526

lib/summary/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ var root,
2020
catalog,
2121
ignores,
2222
unchanged,
23-
sortedBy;
23+
sortedBy,
24+
disableTitleFormatting;
2425

2526
// Get options
2627
function init(options) {
@@ -34,6 +35,7 @@ function init(options) {
3435
unchanged = options.unchanged || bookConfig.unchanged;
3536
bookname = options.bookname || bookConfig.bookname;
3637
sortedBy = options.sortedBy || bookConfig.sortedBy;
38+
disableTitleFormatting = options.disableTitleFormatting || bookConfig.disableTitleFormatting;
3739
}
3840

3941
// Get summary
@@ -166,9 +168,8 @@ function prettyCatalogName(fileName) {
166168
fileName = fileName.match(folderNameReg)[1];
167169
}
168170
}
169-
170171
// Don`t format the files like `req.options.*` using dot, unchanged or Chinese string.
171-
if (_.size(fileName.split(".")) > 1 || _.includes(unchanged, fileName) || isChinese(fileName)) {
172+
if (_.size(fileName.split(".")) > 1 || _.includes(unchanged, fileName) || isChinese(fileName) || disableTitleFormatting) {
172173
return fileName;
173174
}
174175
return _.startCase(fileName);

0 commit comments

Comments
 (0)