Skip to content

Commit

Permalink
docs: deploy docs using netlify (#4774)
Browse files Browse the repository at this point in the history
This adds in the legacy docs into the repo and enables automatic deployment via netlify. The netlify-docs.js script will error out the build on netlify on master if we're not on a tagged commit so that it won't redeploy the docs unless there's a new release. If we're not on master or on master with a tagged commit, it will process with the deploy.
Also, this removes the API docs from being published with npm, fixes #4609.
  • Loading branch information
gkatsev authored Dec 4, 2017
1 parent 0f1b260 commit 4dd000c
Show file tree
Hide file tree
Showing 116 changed files with 53,331 additions and 2 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
!dist/**
!es5/**
!src/css/**
!docs/api/**
19 changes: 19 additions & 0 deletions build/netlify-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const sh = require('shelljs');

const GIT_CONTAINS = `git tag --contains ${process.env.COMMIT_REF}`;

const output = sh.exec(GIT_CONTAINS, {async: false, silent:true}).stdout;

// if we're on master branch and not on a tagged commit,
// error the build so it doesn't redeploy the docs
if (process.env.BRANCH === 'master' && output === '') {
process.exit(1);

// if we're on any other branch, we can regenerate docs
} else {
// generate the docs
sh.exec('npm run docs:api');

// copy the legacy docs over
sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs');
}
1 change: 1 addition & 0 deletions docs/legacy-docs/api/assets/api-doc-template-min.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="//use.edgefonts.net/source-code-pro.js"></script> <link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700" rel="stylesheet" type="text/css"> <!-- there are many other style for highlighted code here: https://cdnjs.com/libraries/highlight.js --> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/atelier-forest.light.min.css"> <link rel="stylesheet" type="text/css" href="css/api-docs.css"> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script> </head> <body> <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script> <script src="js/doc-data.js"></script> <script src="js/api-docs.js"></script> </body> </html>
1 change: 1 addition & 0 deletions docs/legacy-docs/api/assets/api-doc-template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="//use.edgefonts.net/source-code-pro.js"></script> <link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700' rel='stylesheet' type='text/css'> <!-- there are many other style for highlighted code here: https://cdnjs.com/libraries/highlight.js --> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/atelier-forest.light.min.css"> <link rel="stylesheet" type="text/css" href="css/api-docs.css"> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script> </head> <body> <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script> <script src="js/doc-data.js"></script> <script src="js/api-docs.js"></script> </body> </html>
16 changes: 16 additions & 0 deletions docs/legacy-docs/api/assets/create-doc-files-test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>

</style>
</head>
<body>
<h4>Check the console for results</h4>
<script src="../js/doc-data.js"></script>
<script src="create-doc-files.js"></script>

</body>
</html>
68 changes: 68 additions & 0 deletions docs/legacy-docs/api/assets/create-doc-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* get a subset of objects in array of objects
* based on some property value
*
* @param {array} targetArray - array to search
* @param {string} objProperty - object property to search
* @param {string|number} value - value of the property to search for
* @return {array} array of objects with matching property value
*/
function getSubArray(targetArray, objProperty, value) {
var i, totalItems = targetArray.length, idxArr = [];
for (i = 0; i < totalItems; i++) {
if (targetArray[i][objProperty] === value) {
idxArr.push(targetArray[i]);
}
}
return idxArr;
}

/**
* create the HTML files for the classes
* @param {array} filenameArray - array of the filenames
*/
function createFiles(filenameArray) {
var i,
iMax = filenameArray.length,
filename,
contentStr = '<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="//use.edgefonts.net/source-code-pro.js"></script> <link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700" rel="stylesheet" type="text/css"> <!-- there are many other style for highlighted code here: https://cdnjs.com/libraries/highlight.js --> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/atelier-forest.light.min.css"> <link rel="stylesheet" type="text/css" href="css/api-docs.css"> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script> </head> <body> <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script> <script src="js/doc-data.js"></script> <script src="js/api-docs.js"></script> </body> </html>';
for (i = 0; i < iMax; i++) {
filename = filenameArray[i];
// create file with name=filename and contents=contentStr
}
}

function createFilenameArray(classData) {
var filenameArray = [],
i,
iMax = classData.length,
item,
str;
// extract the filenames from the class items
for (i = 0; i < iMax; i++) {
item = classData[i];
str = item.meta.filename;
str = str.substr(str.lastIndexOf('/') + 1);
str = str.replace('.js', '.html');
filenameArray.push(str);
}
// videojs is special case
filenameArray.push('video.html');
filenameArray = filenameArray.sort();
console.log('filenameArray', filenameArray);
// now create the files
createFiles(filenameArray);
}
/**
* extracts class items from doc data
* @param {array} docData JSON output from JSDoc
*/
function getClassData(docData) {
var classData = [];
// extract the class items from the doc data
classData = getSubArray(docData, 'kind', 'class');
// now create the array of filenames
createFilenameArray(classData);
}

getClassData(docData);
Loading

0 comments on commit 4dd000c

Please sign in to comment.