Skip to content

Commit

Permalink
Merge branch 'master' into mvenkov/add-inheritdoc-to-comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bazal4o authored Nov 6, 2018
2 parents 194b2b0 + 27086bf commit 960eb99
Show file tree
Hide file tree
Showing 4 changed files with 674 additions and 431 deletions.
32 changes: 30 additions & 2 deletions extras/docs/themes/sassdoc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,22 @@ const extend = require('extend');
const extras = require('sassdoc-extras');

const lunr = require('lunr');
const fs = require('fs');
const sassPlug = require('sassdoc-plugin-localization');


themeleon.use({

/**
* Builds a structure of json files which represents the retrieved comments per every sass declaration.
*/
convert: (data, dir) => sassPlug.convert(data, dir),
/**
* Compares and replaces the applied translations from the jsons structure.
*/
render: (data, dir) => sassPlug.render(data, dir)
});

// const {convert} = require('./localization/index');
/**
* The theme function. You can directly export it like this:
*
Expand All @@ -33,6 +48,12 @@ const fs = require('fs');
* The theme function describes the steps to render the theme.
*/
const theme = themeleon(__dirname, function (t) {
/**
* If only json conversion is needed the whole process of documentation rendering has to be stopped.
*/
if (t.ctx.convert) {
return t.convert(t.ctx._data, './extras/sassdoc/en');
}
/**
* Copy the assets folder from the theme's directory in the
* destination directory.
Expand Down Expand Up @@ -91,8 +112,15 @@ const theme = themeleon(__dirname, function (t) {
* as `index.html` in the destination directory.
*/
t.handlebars('views/index.hbs', 'index.html', options);
});

/**
* Applies the translations from the json files.
*/
if (t.ctx.render) {
const jsonDir = t.ctx.jsonDir ? t.ctx.jsonDir : './extras/sassdoc/en';
t.render(t.ctx._data, jsonDir);
}
});
/**
* Actual theme function. It takes the destination directory `dest`
* (that will be handled by Themeleon), and the context variables `ctx`.
Expand Down
71 changes: 55 additions & 16 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const postcss = require('gulp-postcss');
const uglify = require('gulp-uglify');
const process = require('process');
const fs = require('fs');
const argv = require('yargs').argv;
const sassdoc = require('sassdoc');
const {
spawnSync
} = require('child_process');
Expand Down Expand Up @@ -204,15 +206,17 @@ gulp.task('typedoc-build', [
'typedoc-js'
]);

const TRANSLATIONS_REPO = {
NAME: 'igniteui-angular-api-ja',
LINK: `https://github.com/IgniteUI/igniteui-angular-api-ja`
};

const DOCS_OUTPUT_PATH = './dist/igniteui-angular/docs/'

const TYPEDOC = {
EXPORT_JSON_PATH: 'dist/igniteui-angular/docs/typescript-exported',
PROJECT_PATH: 'projects/igniteui-angular/src',
TEMPLATE_STRINGS_PATH: 'extras/template/strings/shell-strings.json',
OUTPUT_PATH: './dist/igniteui-angular/docs/',
REPO: {
TRANSLATIONS_REPO_NAME: 'igniteui-angular-api-ja',
TRANSLATIONS_REPO_LINK: `https://github.com/IgniteUI/igniteui-angular-api-ja`
}
}

gulp.task('typedoc-build:theme', ['typedoc-build'],
Expand All @@ -227,30 +231,65 @@ gulp.task('typedoc-build:import', ['typedoc-build'],
shell.task(`typedoc ${TYPEDOC.PROJECT_PATH} --generate-from-json ${TYPEDOC.EXPORT_JSON_PATH}`)
);

gulp.task('typedoc:clean-translations', () => {
del.sync(`${TYPEDOC.OUTPUT_PATH}/${TYPEDOC.REPO.TRANSLATIONS_REPO_NAME}`)
gulp.task('clean-translations:localization:repo', () => {
del.sync(`${DOCS_OUTPUT_PATH}/${TRANSLATIONS_REPO.NAME}`)
});

gulp.task('typedoc:create-output-path', () => {
!fs.existsSync(TYPEDOC.OUTPUT_PATH) && fs.mkdirSync(TYPEDOC.OUTPUT_PATH);
gulp.task('create:docs-output-path', () => {
!fs.existsSync(DOCS_OUTPUT_PATH) && fs.mkdirSync(DOCS_OUTPUT_PATH);
});

gulp.task('typedoc:copy-translations', ['typedoc:clean-translations', 'typedoc:create-output-path'],
shell.task(`git -C ${TYPEDOC.OUTPUT_PATH} clone ${TYPEDOC.REPO.TRANSLATIONS_REPO_LINK}`)
gulp.task('copy-translations:localization:repo', ['clean-translations:localization:repo', 'create:docs-output-path'],
shell.task(`git -C ${DOCS_OUTPUT_PATH} clone ${TRANSLATIONS_REPO.LINK}`)
);

gulp.task('typedoc:clean-docs-dir', () => {
del.sync(`${TYPEDOC.OUTPUT_PATH}typescript`)
del.sync(`${DOCS_OUTPUT_PATH}typescript`)
});

gulp.task('typedoc-build:doc:ja:localization', ['typedoc-build', 'typedoc:clean-docs-dir', 'typedoc:copy-translations'],
shell.task(`typedoc ${TYPEDOC.PROJECT_PATH} --generate-from-json ${TYPEDOC.OUTPUT_PATH}/${TYPEDOC.REPO.TRANSLATIONS_REPO_NAME}/ja/ --templateStrings ${TYPEDOC.TEMPLATE_STRINGS_PATH} --localize jp`)
gulp.task('typedoc-build:doc:ja:localization', ['typedoc-build', 'typedoc:clean-docs-dir', 'copy-translations:localization:repo'],
shell.task(`typedoc ${TYPEDOC.PROJECT_PATH} --generate-from-json ${DOCS_OUTPUT_PATH}/${TRANSLATIONS_REPO.NAME}/ja/ --templateStrings ${TYPEDOC.TEMPLATE_STRINGS_PATH} --localize jp`)
);

gulp.task('typedoc-build:doc:en:localization', ['typedoc-build', 'typedoc:clean-docs-dir', 'typedoc:copy-translations'],
shell.task(`typedoc ${TYPEDOC.PROJECT_PATH} --generate-from-json ${TYPEDOC.OUTPUT_PATH}/${TYPEDOC.REPO.TRANSLATIONS_REPO_NAME}/en/`)
gulp.task('typedoc-build:doc:en:localization', ['typedoc-build', 'typedoc:clean-docs-dir', 'copy-translations:localization:repo'],
shell.task(`typedoc ${TYPEDOC.PROJECT_PATH} --generate-from-json ${DOCS_OUTPUT_PATH}/${TRANSLATIONS_REPO.NAME}/en/`)
);

const SASSDOC = {
PROJECT_PATH: "projects/igniteui-angular/src/lib/core/styles",
DEST: "./dist/igniteui-angular/docs/sass",
OPTIONS: JSON.parse(fs.readFileSync('./.sassdocrc', 'utf8')),
}

gulp.task('sassdoc:clean-docs-dir', () => {
del.sync(SASSDOC.DEST);
});

gulp.task('sassdoc-build:export', () => {
const options = SASSDOC.OPTIONS;
options.convert = argv.convert;

return gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
.pipe(sassdoc(options));
});

gulp.task('sassdoc-build:import', () => {
const options = SASSDOC.OPTIONS;
options.render = argv.render;

return gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
.pipe(sassdoc(options))
});

gulp.task('sassdoc-build:doc:ja:localizaiton', ['sassdoc:clean-docs-dir', 'copy-translations:localization:repo'], () => {
const options = SASSDOC.OPTIONS;
options.render = argv.render;
options.jsonDir = `${DOCS_OUTPUT_PATH}/${TRANSLATIONS_REPO.NAME}/sassdoc/jp/`;

return gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
.pipe(sassdoc(options));
});

gulp.task('typedoc-serve', ['typedoc-watch'], () => {
browserSync.init({
server: './dist/igniteui-angular/docs/typescript'
Expand Down
Loading

0 comments on commit 960eb99

Please sign in to comment.