From 27daced93ec82e38af03dedf3b5beff9c52cf776 Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Mon, 7 Jan 2019 00:41:23 +0300 Subject: [PATCH] Artifact picker functionality for docs site --- docs/.vuepress/.artifacts.js | 4 + docs/.vuepress/components/ArtifactPicker.vue | 122 +++++++++++++++++++ docs/.vuepress/style.styl | 3 + docs/collectArtifacts.js | 50 ++++++++ docs/package-lock.json | 6 +- docs/package.json | 2 +- markwon/gradle.properties | 3 +- 7 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 docs/.vuepress/.artifacts.js create mode 100644 docs/.vuepress/components/ArtifactPicker.vue create mode 100644 docs/collectArtifacts.js diff --git a/docs/.vuepress/.artifacts.js b/docs/.vuepress/.artifacts.js new file mode 100644 index 00000000..8b93cea3 --- /dev/null +++ b/docs/.vuepress/.artifacts.js @@ -0,0 +1,4 @@ + +// this is a generated file, do not modify. To update it run 'collectArtifacts.js' script +const artifacts = [{"id":"markwon","name":"Markwon","group":"ru.noties","description":"Core Markwon artifact that includes basic markdown parsing and rendering"},{"id":"markwon-ext-strikethrough","name":"Markwon-Ext-Strikethrough","group":"ru.noties"},{"id":"markwon-html-parser-impl","name":"Markwon","group":"ru.noties"},{"id":"markwon-syntax-highlight","name":"Markwon","group":"ru.noties"},{"id":"markwon-view","name":"Markwon-View","group":"ru.noties"}]; +export { artifacts }; diff --git a/docs/.vuepress/components/ArtifactPicker.vue b/docs/.vuepress/components/ArtifactPicker.vue new file mode 100644 index 00000000..83d6c9cb --- /dev/null +++ b/docs/.vuepress/components/ArtifactPicker.vue @@ -0,0 +1,122 @@ + + + + + \ No newline at end of file diff --git a/docs/.vuepress/style.styl b/docs/.vuepress/style.styl index e69de29b..71f493f4 100644 --- a/docs/.vuepress/style.styl +++ b/docs/.vuepress/style.styl @@ -0,0 +1,3 @@ +div[class~=language-gradle]:before { + content:"gradle" +} \ No newline at end of file diff --git a/docs/collectArtifacts.js b/docs/collectArtifacts.js new file mode 100644 index 00000000..959999cf --- /dev/null +++ b/docs/collectArtifacts.js @@ -0,0 +1,50 @@ +const fs = require('fs'); +const path = require('path'); + +const PROPERTIES_FILE_NAME = 'gradle.properties'; +const PROP_GROUP = 'GROUP'; +const PROP_DESCRIPTION = 'POM_DESCRIPTION'; +const PROP_ARTIFACT_NAME = 'POM_NAME'; +const PROP_ARTIFACT_ID = 'POM_ARTIFACT_ID'; + +const readProperties = (file) => fs.readFileSync(file, { encoding: 'utf-8' }, 'string') + .split('\n') + // filter-out empty lines + .filter(s => s) + .map(s => s.split('=')) + .reduce((a, s) => { + a[s[0]] = s[1]; + return a; + }, {}); + +const listDirectories = (folder) => fs.readdirSync(folder) + .map(name => path.join(folder, name)) + .filter(f => fs.lstatSync(f).isDirectory()); + +const projectDir = path.resolve(__dirname, '../'); + +const projectProperties = readProperties(path.join(projectDir, PROPERTIES_FILE_NAME)); + +const projectGroup = projectProperties[PROP_GROUP] + +const artifacts = listDirectories(projectDir) + .map(dir => path.join(dir, PROPERTIES_FILE_NAME)) + .filter(f => fs.existsSync(f)) + .map(readProperties) + .map(props => { + return { + id: props[PROP_ARTIFACT_ID], + name: props[PROP_ARTIFACT_NAME], + group: projectGroup, + description: props[PROP_DESCRIPTION] + } + }); + +const artifactsFile = path.join(__dirname, '.vuepress', '.artifacts.js'); +const artifactsJs = ` +// this is a generated file, do not modify. To update it run 'collectArtifacts.js' script +const artifacts = ${JSON.stringify(artifacts)}; +export { artifacts }; +` + +fs.writeFileSync(artifactsFile, artifactsJs); diff --git a/docs/package-lock.json b/docs/package-lock.json index 5cc23227..77f560a6 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -5465,9 +5465,9 @@ } }, "linkify-it": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.0.3.tgz", - "integrity": "sha1-2UpGSPmxwXnWT6lykSaL22zpQ08=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.1.0.tgz", + "integrity": "sha512-4REs8/062kV2DSHxNfq5183zrqXMl7WP0WzABH9IeJI+NLm429FgE1PDecltYfnOoFDFlZGh2T8PfZn0r+GTRg==", "requires": { "uc.micro": "^1.0.1" } diff --git a/docs/package.json b/docs/package.json index d469413c..9ba0ddb5 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "scripts": { - "docs:build": "vuepress build" + "docs:build": "node ./collectArtifacts.js && vuepress build" }, "dependencies": { "markdown-it-task-lists": "^2.1.1", diff --git a/markwon/gradle.properties b/markwon/gradle.properties index e1d2806a..367bfbc2 100644 --- a/markwon/gradle.properties +++ b/markwon/gradle.properties @@ -1,3 +1,4 @@ POM_NAME=Markwon POM_ARTIFACT_ID=markwon -POM_PACKAGING=aar \ No newline at end of file +POM_PACKAGING=aar +POM_DESCRIPTION=Core Markwon artifact that includes basic markdown parsing and rendering \ No newline at end of file