mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4152] Updated doc folder structure and index tool (#4403)
* [ADF-4152] Initial GraphQL implementation * [ADF-4152] Schema updates * [ADF-4152] Rounded out basic fields * [ADF-4152] Added basic template functionality * [ADF-4152] Added full template generation * [ADF-4152] Moved proc services doc files to new folders * [ADF-4152] Updated README.md with section from new template * [ADF-4152] Fixed another problem with relative URLs * [ADF-4152] Fixed links and some more bugs * [ADF-4152] Removed proc services folder README file
This commit is contained in:
committed by
Eugenio Romano
parent
75b90c5e08
commit
e74f545aa8
51
tools/doc/remarkGraphQl.ts
Normal file
51
tools/doc/remarkGraphQl.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import { graphql, buildSchema } from 'graphql';
|
||||
|
||||
import * as remark from 'remark';
|
||||
import * as frontMatter from 'remark-frontmatter';
|
||||
import { MDAST } from 'mdast';
|
||||
import * as removePosInfo from 'unist-util-remove-position';
|
||||
|
||||
import * as MQ from './mqDefs';
|
||||
|
||||
let docFilePath = path.resolve('..', '..', 'docs', 'core', 'about.component.md');
|
||||
let docSrc = fs.readFileSync(docFilePath, 'utf8');
|
||||
|
||||
let tree: MDAST.Root = remark()
|
||||
.use(frontMatter, ["yaml"])
|
||||
.parse(docSrc);
|
||||
|
||||
tree = removePosInfo(tree);
|
||||
|
||||
//console.log(JSON.stringify(tree));
|
||||
|
||||
let schema = buildSchema(MQ.schema);
|
||||
|
||||
let root = {
|
||||
document: () => new MQ.Root(tree)
|
||||
};
|
||||
|
||||
|
||||
let query = `
|
||||
{
|
||||
document {
|
||||
metadata(key: "Status")
|
||||
heading {
|
||||
link {
|
||||
text {
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
paragraph {
|
||||
plaintext
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
graphql(schema, query, root).then((response) => {
|
||||
console.log(JSON.stringify(response));
|
||||
});
|
Reference in New Issue
Block a user