Skip to content

Commit 475a4d4

Browse files
authored
Merge pull request #96 from tomcollins/normalise-paths
Improve path handling when creating docs index.
2 parents caed396 + a47f6cd commit 475a4d4

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

gh-pages/examples/examples-index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
- [oneof.html](oneof.html)
66
- [person.html](person.html)
77

8-
## Draft-06
9-
- [draft-06/animal.html](draft-06/animal.html)
10-
118
## Draft-07
129
- [draft-07/user.html](draft-07/user.html)
1310

11+
## Draft-06
12+
- [draft-06/animal.html](draft-06/animal.html)
13+
1414
## Draft-2019-09
1515
- [draft-2019-09/array.html](draft-2019-09/array.html)

lib/json-schema-static-docs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const defaultOptions = {
2828

2929
var JsonSchemaStaticDocs = function (options) {
3030
this._options = extend(true, defaultOptions, options);
31+
32+
this._options.inputPath = this._options.inputPath.replace(/\/$/, "");
33+
this._options.outputPath = this._options.outputPath.replace(/\/$/, "");
3134
};
3235

3336
JsonSchemaStaticDocs.prototype.generate = async function () {

lib/renderer/index.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@ const path = require("path");
33
const fg = require("fast-glob");
44

55
const removeSourcePathPrefix = (filename, sourcePath) => {
6-
let result = filename
7-
.replace(
8-
new RegExp(
9-
`/Users/collinst/Workspace/json-schema-static-docs/gh-pages/examples`
10-
),
11-
""
12-
)
13-
.replace(/^\//, "");
14-
6+
let result = filename.replace(new RegExp(sourcePath), "").replace(/^\//, "");
157
return result;
168
};
179

@@ -99,7 +91,9 @@ const sortFilenames = (filenames) => {
9991
const createIndex = async (indexPath, sourcePath, options) => {
10092
options = options || {};
10193

102-
let files = await fg([sourcePath + "/**"]);
94+
const globPattern = path.join(sourcePath, "/**");
95+
96+
let files = await fg([globPattern]);
10397
files = sortFilenames(files);
10498

10599
let title = options.title || "Index of Schema";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-schema-static-docs",
3-
"version": "0.22.0",
3+
"version": "0.22.1",
44
"description": "Generates static documentation for humans based on the contents of JSON schema files (yml or json).",
55
"main": "lib/json-schema-static-docs.js",
66
"bin": {

0 commit comments

Comments
 (0)