Skip to content

Commit 2e5aa30

Browse files
committed
DocumentedInterface -> Manifest (better name!)
1 parent a596549 commit 2e5aa30

File tree

10 files changed

+52
-52
lines changed

10 files changed

+52
-52
lines changed

packages/webdoc-cli/src/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ async function main(argv: yargs.Argv) {
119119

120120
log.info(tag.Parser, "Parsing stage finished!");
121121

122-
const documentedInterface = external.fromTree(documentTree);
122+
const manifest = external.fromTree(documentTree);
123123
const db = exportTaffy(documentTree);
124124

125-
documentedInterface.metadata.linker = "(unsigned)";
126-
documentedInterface.metadata.siteDomain = config.template.siteDomain;
127-
documentedInterface.metadata.siteRoot = config.template.siteRoot;
125+
manifest.metadata.linker = "(unsigned)";
126+
manifest.metadata.siteDomain = config.template.siteDomain;
127+
manifest.metadata.siteRoot = config.template.siteRoot;
128128

129129
const _path = `${getTemplate(config)}/publish`;
130130
// $FlowFixMe[unsupported-syntax]
@@ -136,7 +136,7 @@ async function main(argv: yargs.Argv) {
136136
config,
137137
doctree: documentTree,
138138
documentTree,
139-
documentedInterface,
139+
manifest,
140140
docDatabase: db,
141141
opts: config.opts,
142142
tutorials,
@@ -154,7 +154,7 @@ async function main(argv: yargs.Argv) {
154154
}
155155

156156
if (config.opts && config.opts.export) {
157-
fs.writeFileSync(config.opts.export, external.write(documentedInterface, argv.verbose));
157+
fs.writeFileSync(config.opts.export, external.write(manifest, argv.verbose));
158158
}
159159

160160
console.log(`@webdoc took ${Math.ceil(performance.now() - start)}ms to run!`);

packages/webdoc-default-template/helper/crawl/crawl.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
RootDoc,
1515
DocType,
1616
} from "@webdoc/types";
17-
import type {DocumentedInterface} from "@webdoc/externalize";
17+
import type {Manifest} from "@webdoc/externalize";
1818
import type {ExplorerTarget} from './crawl-reference-explorer';
1919
2020
export type CategorizedDocumentList = {
@@ -31,12 +31,12 @@ declare function crawl(tree: RootDoc, index: string): CrawlData;
3131
*/
3232

3333
function crawl(
34-
documentedInterface /*: DocumentedInterface */,
34+
manifest /*: Manifest */,
3535
index /*: string */,
3636
)/*: CrawlData */ {
37-
const tree = documentedInterface.root;
37+
const tree = manifest.root;
3838

39-
buildLinks(documentedInterface);
39+
buildLinks(manifest);
4040

4141
const crawlData /*: CrawlData */ = {
4242
index: buildIndex(tree),
@@ -67,10 +67,10 @@ function crawl(
6767

6868
module.exports = ({crawl}/*: {crawl: typeof crawl} */);
6969

70-
function buildLinks(documentedInterface /*: DocumentedInterface */) /*: void */ {
71-
const registry = documentedInterface.registry;
70+
function buildLinks(manifest /*: Manifest */) /*: void */ {
71+
const registry = manifest.registry;
7272

73-
model.traverse(documentedInterface.root, (doc) => {
73+
model.traverse(manifest.root, (doc) => {
7474
if (doc.type === "RootDoc") {
7575
doc.packages.forEach((packageDoc) => {
7676
if (!registry[packageDoc.id]) {

packages/webdoc-default-template/helper/linker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports.prepareLinker = async function(config) {
88

99
if (Array.isArray(config.opts.import)) {
1010
for (const importUri of config.opts.import) {
11-
await linker.loadDocumentedInterface(importUri);
11+
await linker.loadManifest(importUri);
1212
}
1313
}
1414
};

packages/webdoc-default-template/publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ exports.publish = async function publish(options /*: PublishOptions */) {
7272

7373
fse.ensureDir(outDir);
7474

75-
const crawlData = crawl(options.documentedInterface, index);
75+
const crawlData = crawl(options.manifest, index);
7676
const appBarItems = _.merge(config.template.appBar.items, {
7777
/* NOTE: config.template.appBar.items is the primary object so we retain the order as the user
7878
desires. */

packages/webdoc-externalize/index.js.flow

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
declare module "@webdoc/externalize" {
22
import type {RootDoc} from "@webdoc/types";
33

4-
declare export type DocumentedInterface = {
4+
declare export type Manifest = {
55
version: string;
66
metadata: {
77
linker?: "require('@webdoc/template-library').LinkerPlugin" | string;
@@ -15,9 +15,9 @@ declare module "@webdoc/externalize" {
1515
};
1616
};
1717

18-
declare export function fromTree(tree: RootDoc): DocumentedInterface;
19-
declare export function read(data: string): DocumentedInterface;
20-
declare export function write(doc: DocumentedInterface): string;
18+
declare export function fromTree(tree: RootDoc): Manifest;
19+
declare export function read(data: string): Manifest;
20+
declare export function write(doc: Manifest): string;
2121

2222
declare export default {
2323
fromTree,

packages/webdoc-externalize/src/read.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as model from "@webdoc/model";
44
import {BASE_PROPS} from "./const";
55
import type {Doc} from "@webdoc/types";
6-
import type {DocumentedInterface} from "./types";
6+
import type {Manifest} from "./types";
77
import _ from "lodash";
88

99
function deserializeTree(serialized: any, parent: ?Doc): Doc {
@@ -45,22 +45,22 @@ function deserializeTree(serialized: any, parent: ?Doc): Doc {
4545
* @param {string} data
4646
* @return {RootDoc}
4747
*/
48-
export default function read(data: string): DocumentedInterface {
49-
const documentedInterface = (JSON.parse(data): any);
48+
export default function read(data: string): Manifest {
49+
const manifest = (JSON.parse(data): any);
5050

51-
if (!("version" in documentedInterface)) {
51+
if (!("version" in manifest)) {
5252
return ({
5353
version: "0.0.0",
5454
metadata: {},
55-
root: (deserializeTree(documentedInterface.root, null): any),
55+
root: (deserializeTree(manifest.root, null): any),
5656
registry: {},
57-
}: DocumentedInterface);
57+
}: Manifest);
5858
}
5959

6060
return {
61-
version: documentedInterface.version,
62-
metadata: documentedInterface.metadata,
63-
root: (deserializeTree(documentedInterface.root, null): any),
64-
registry: documentedInterface.registry,
61+
version: manifest.version,
62+
metadata: manifest.metadata,
63+
root: (deserializeTree(manifest.root, null): any),
64+
registry: manifest.registry,
6565
};
6666
}

packages/webdoc-externalize/src/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type SerializedReturn = {
2424
dataType: SerializedDataType,
2525
};
2626

27-
export type DocumentedInterface = {
27+
export type Manifest = {
2828
version: string;
2929
metadata: {
3030
siteRoot?: string;

packages/webdoc-externalize/src/write.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
RootDoc,
1515
} from "@webdoc/types";
1616
import type {
17-
DocumentedInterface,
17+
Manifest,
1818
SerializedDataType,
1919
SerializedParam,
2020
SerializedReturn,
@@ -121,34 +121,34 @@ function serializeTree(doc: Doc): any {
121121
* Create an documented interface the document tree, with no metadata.
122122
*
123123
* @param {RootDoc} documentTree
124-
* @return {DocumentedInterface}
124+
* @return {Manifest}
125125
*/
126-
export function fromTree(documentTree: RootDoc): DocumentedInterface {
127-
const documentedInterface = {
126+
export function fromTree(documentTree: RootDoc): Manifest {
127+
const manifest = {
128128
version: LATEST_VERSION,
129129
metadata: {},
130130
root: documentTree,
131131
registry: {},
132132
};
133133

134-
return documentedInterface;
134+
return manifest;
135135
}
136136

137137
/**
138138
* Serialize the documented interface into a JSON string.
139139
*
140-
* @param {DocumentedInterface} documentedInterface
140+
* @param {Manifest} manifest
141141
* @param {boolean}[indent=false] - Whether to indent
142142
* @return {string} - Serialized JSON string
143143
* @see serializeTree
144144
*/
145-
export default function write(documentedInterface: DocumentedInterface, indent?: boolean): string {
145+
export default function write(manifest: Manifest, indent?: boolean): string {
146146
return JSON.stringify(
147147
{
148-
version: documentedInterface.version,
149-
metadata: documentedInterface.metadata,
150-
root: serializeTree(documentedInterface.root),
151-
registry: documentedInterface.registry,
148+
version: manifest.version,
149+
metadata: manifest.metadata,
150+
root: serializeTree(manifest.root),
151+
registry: manifest.registry,
152152
},
153153
null,
154154
indent ? "\t" : "",

packages/webdoc-externalize/test/read-write.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ describe("@webdoc/externalize (read-write test)", function() {
3333
*/
3434
`);
3535

36-
const documentedInterface = external.fromTree(inputTree);
37-
const {root: outputTree} = external.read(external.write(documentedInterface));
36+
const manifest = external.fromTree(inputTree);
37+
const {root: outputTree} = external.read(external.write(manifest));
3838

3939
expect(outputTree.members.length).to.equal(2);
4040

packages/webdoc-template-library/src/template-plugins/LinkerPlugin.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ function LinkerPluginShell() {
130130

131131
/**
132132
* Loaded documented interfaces that can be used to resolve links to external APIs.
133-
* @type {DocumentedInterface[]}
133+
* @type {Manifest[]}
134134
*/
135-
loadedInterfaces = [];
135+
importedManifests = [];
136136

137137
/**
138138
* Load the documented interface into this linker so you can resolve links to those documents.
@@ -141,7 +141,7 @@ function LinkerPluginShell() {
141141
* or a file ./apis/lib.json)
142142
* @return {Promise<void>}
143143
*/
144-
async loadDocumentedInterface(uri: string) {
144+
async loadManifest(uri: string) {
145145
let isURL = true;
146146

147147
try {
@@ -158,9 +158,9 @@ function LinkerPluginShell() {
158158
contents = await fs.readFile(path.join(process.cwd(), uri), "utf8");
159159
}
160160

161-
const documentedInterface = external.read(contents);
162-
const {registry} = documentedInterface;
163-
const {siteDomain, siteRoot} = documentedInterface.metadata;
161+
const manifest = external.read(contents);
162+
const {registry} = manifest;
163+
const {siteDomain, siteRoot} = manifest.metadata;
164164

165165
if (!siteDomain) {
166166
throw new Error("Imported documented interfaces must have a siteDomain!");
@@ -175,7 +175,7 @@ function LinkerPluginShell() {
175175
}
176176
}
177177

178-
this.loadedInterfaces.push(documentedInterface);
178+
this.importedManifests.push(manifest);
179179
}
180180

181181
/**
@@ -320,8 +320,8 @@ function LinkerPluginShell() {
320320
this.queryCache.set(docPath, fileUrl);
321321
}
322322
} else {
323-
for (let i = 0; i < this.loadedInterfaces.length && !fileUrl; i++) {
324-
const externalInterface = this.loadedInterfaces[i];
323+
for (let i = 0; i < this.importedManifests.length && !fileUrl; i++) {
324+
const externalInterface = this.importedManifests[i];
325325
const doc = query(docPath, externalInterface.root)[0];
326326

327327
if (doc) {

0 commit comments

Comments
 (0)