mirror of
https://github.com/vale981/grapher
synced 2025-03-05 17:41:41 -05:00
added documentation exposure
This commit is contained in:
parent
378fd65aae
commit
45cf24befe
3 changed files with 56 additions and 2 deletions
50
lib/documentor/index.js
Normal file
50
lib/documentor/index.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import { linkStorage } from '../links/symbols.js';
|
||||||
|
|
||||||
|
export default function extractDocumentation() {
|
||||||
|
const collections = Mongo.Collection.getAll();
|
||||||
|
let DocumentationObject = {};
|
||||||
|
|
||||||
|
_.each(collections, ({name, instance}) => {
|
||||||
|
if (name.substr(0, 7) == 'meteor_') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DocumentationObject[name] = {};
|
||||||
|
extractSchema(DocumentationObject[name], instance);
|
||||||
|
extractLinks(DocumentationObject[name], instance);
|
||||||
|
});
|
||||||
|
|
||||||
|
return DocumentationObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function extractSchema(storage, collection) {
|
||||||
|
storage.schema = {};
|
||||||
|
|
||||||
|
if (collection.simpleSchema && collection.simpleSchema()) {
|
||||||
|
storage.schema = collection.simpleSchema()._schema;
|
||||||
|
_.each(storage.schema, (value, key) => {
|
||||||
|
if (value.type && value.type.name) {
|
||||||
|
value.type = value.type.name;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractLinks(storage, collection) {
|
||||||
|
storage.links = {};
|
||||||
|
const collectionLinkStorage = collection[linkStorage];
|
||||||
|
|
||||||
|
_.each(collectionLinkStorage, (linker, name) => {
|
||||||
|
storage.links[name] = {
|
||||||
|
collection: !linker.isResolver() ? linker.getLinkedCollection()._name : null,
|
||||||
|
strategy: linker.strategy,
|
||||||
|
metadata: linker.linkConfig.metadata,
|
||||||
|
isVirtual: linker.isVirtual(),
|
||||||
|
isResolver: linker.isResolver(),
|
||||||
|
resolverFunction: linker.isResolver() ? linker.linkConfig.resolve.toString() : null,
|
||||||
|
field: linker.linkConfig.field,
|
||||||
|
isOneResult: linker.isOneResult()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
|
@ -14,3 +14,7 @@ export {
|
||||||
export {
|
export {
|
||||||
default as Exposure
|
default as Exposure
|
||||||
} from './lib/exposure/exposure.js';
|
} from './lib/exposure/exposure.js';
|
||||||
|
|
||||||
|
export {
|
||||||
|
default as getDocumentationObject
|
||||||
|
} from './lib/documentor/index.js';
|
|
@ -1,6 +1,6 @@
|
||||||
Package.describe({
|
Package.describe({
|
||||||
name: 'cultofcoders:grapher',
|
name: 'cultofcoders:grapher',
|
||||||
version: '1.1.5',
|
version: '1.1.6',
|
||||||
// Brief, one-line summary of the package.
|
// Brief, one-line summary of the package.
|
||||||
summary: 'Grapher makes linking collections easily. And fetching data as a graph.',
|
summary: 'Grapher makes linking collections easily. And fetching data as a graph.',
|
||||||
// URL to the Git repository containing the source code for this package.
|
// URL to the Git repository containing the source code for this package.
|
||||||
|
|
Loading…
Add table
Reference in a new issue