mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-20 21:35:42 +02:00
Resolves #1201 -- basic script to output all levels
This commit is contained in:
parent
aeebce4dac
commit
4cfaa0ae02
3 changed files with 3115 additions and 464 deletions
1254
generatedDocs/github-markdown.css
Normal file
1254
generatedDocs/github-markdown.css
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
58
gulpfile.js
58
gulpfile.js
|
@ -5,6 +5,7 @@ var {
|
||||||
} = require('fs');
|
} = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
|
var { marked } = require('marked');
|
||||||
var glob = require('glob');
|
var glob = require('glob');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
|
|
||||||
|
@ -136,6 +137,11 @@ var clean = function () {
|
||||||
.pipe(gClean());
|
.pipe(gClean());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var convertMarkdownStringsToHTML = function(markdowns) {
|
||||||
|
return marked(markdowns.join('\n'));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var jshint = function() {
|
var jshint = function() {
|
||||||
return src([
|
return src([
|
||||||
'gulpfile.js',
|
'gulpfile.js',
|
||||||
|
@ -204,15 +210,17 @@ var generateLevelDocs = function(done) {
|
||||||
log('Generating level documentation...');
|
log('Generating level documentation...');
|
||||||
|
|
||||||
// Get all level files
|
// Get all level files
|
||||||
const levelFiles = glob.sync('src/levels/**/*.js');
|
const allLevels= require('./src/levels/index');
|
||||||
|
const cssContent = readFileSync('./generatedDocs/github-markdown.css');
|
||||||
|
|
||||||
let htmlContent = `
|
let htmlContent = `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Learn Git Branching - Level Documentation</title>
|
<title>Learn Git Branching - Level Documentation</title>
|
||||||
|
<style>${cssContent}</style>
|
||||||
<style>
|
<style>
|
||||||
body { font-family: Arial, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }
|
body { font-family: Arial, sans-serif; max-width: 1200px; margin: 0 auto; padding: 40px; }
|
||||||
.level { margin-bottom: 30px; border-bottom: 1px solid #eee; padding-bottom: 20px; }
|
.level { margin-bottom: 30px; border-bottom: 1px solid #eee; padding-bottom: 20px; }
|
||||||
.level-name { color: #333; }
|
.level-name { color: #333; }
|
||||||
.level-goal { background: #f5f5f5; padding: 10px; border-radius: 4px; }
|
.level-goal { background: #f5f5f5; padding: 10px; border-radius: 4px; }
|
||||||
|
@ -221,32 +229,42 @@ var generateLevelDocs = function(done) {
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Learn Git Branching - Level Documentation</h1>
|
<div class="markdown-body">
|
||||||
|
<h1>Learn Git Branching - All Levels Documentation</h1>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
levelFiles.forEach(file => {
|
Object.keys(allLevels.sequenceInfo).forEach(sequenceKey => {
|
||||||
const content = require('./' + file.replace('.js', ''));
|
log('Processing sequence: ', sequenceKey);
|
||||||
const level = content.level;
|
|
||||||
|
|
||||||
if (!level) return; // Skip if not a valid level file
|
|
||||||
|
|
||||||
|
const sequenceInfo = allLevels.sequenceInfo[sequenceKey];
|
||||||
htmlContent += `
|
htmlContent += `
|
||||||
<div class="level">
|
<h2>Level Sequence: ${sequenceInfo.displayName.en_US}</h2>
|
||||||
<h2 class="level-name">${level.name?.en_US || 'Unnamed Level'}</h2>
|
<h6>${sequenceInfo.about.en_US}</h6>
|
||||||
|
|
||||||
<h3>Goal Tree:</h3>
|
|
||||||
<pre class="level-goal">${level.goalTreeString || 'No goal tree specified'}</pre>
|
|
||||||
|
|
||||||
<h3>Solution:</h3>
|
|
||||||
<pre class="level-solution">${level.solutionCommand || 'No solution specified'}</pre>
|
|
||||||
|
|
||||||
<h3>Hint:</h3>
|
|
||||||
<p class="level-hint">${level.hint?.en_US || 'No hint available'}</p>
|
|
||||||
</div>
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const levels = allLevels.levelSequences[sequenceKey];
|
||||||
|
for (const level of levels) {
|
||||||
|
htmlContent += `<h3>Level: ${level.name.en_US}</h3>`;
|
||||||
|
|
||||||
|
const startDialog = level.startDialog.en_US;
|
||||||
|
for (const dialog of startDialog.childViews) {
|
||||||
|
const childViewType = dialog.type;
|
||||||
|
if (childViewType === 'ModalAlert') {
|
||||||
|
htmlContent += convertMarkdownStringsToHTML(dialog.options.markdowns);
|
||||||
|
} else if (childViewType === 'GitDemonstrationView') {
|
||||||
|
htmlContent += convertMarkdownStringsToHTML(dialog.options.beforeMarkdowns);
|
||||||
|
htmlContent += `<pre class="level-solution">${dialog.options.command}</pre>`;
|
||||||
|
htmlContent += convertMarkdownStringsToHTML(dialog.options.afterMarkdowns);
|
||||||
|
} else {
|
||||||
|
throw new Error(`Unknown child view type: ${childViewType}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
htmlContent += `
|
htmlContent += `
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue