@@ -24,7 +24,12 @@ let user_config = {
2424 highlight_theme : ""
2525}
2626
27- async function download_files ( files , tree ) {
27+ /**
28+ * Downloads a list of files from the GitHub repo
29+ * @param files Array of files' names
30+ * @param tree Array of repo nodes containing the files' paths/names and urls
31+ */
32+ async function download_files ( files : Array < string > , tree : Array < any > ) {
2833 for ( const node of tree ) {
2934 for ( const g of files ) {
3035 if ( node . path . includes ( g ) ) {
@@ -42,6 +47,9 @@ async function download_files(files, tree) {
4247 }
4348}
4449
50+ /**
51+ * Saves the current GitHub repo structure tree for later consulting
52+ */
4553async function create_cache ( ) {
4654 return fetch ( url , { method : "Get" } )
4755 . then ( ( response ) => {
@@ -56,6 +64,11 @@ async function create_cache() {
5664 } )
5765}
5866
67+ /**
68+ * Gets the list of themes currently available in the GitHub repo
69+ * @param tree Array of repo nodes containing the files' paths/names and urls
70+ * @returns The list of themes' names
71+ */
5972function get_themes ( tree ) : Array < string > {
6073
6174 let themes = [ ]
@@ -69,6 +82,11 @@ function get_themes(tree): Array<string> {
6982 return themes
7083}
7184
85+ /**
86+ * Gets the list of fonts currently available in the GitHub repo
87+ * @param tree Array of repo nodes containing the files' paths/names and urls
88+ * @returns The list of fonts' names
89+ */
7290function get_fonts ( tree ) : Array < string > {
7391
7492 let fonts = [ ]
@@ -82,6 +100,11 @@ function get_fonts(tree): Array<string> {
82100 return fonts
83101}
84102
103+ /**
104+ * Gets the list of plugins currently available in the GitHub repo
105+ * @param tree Array of repo nodes containing the files' paths/names and urls
106+ * @returns The list of plugins' names
107+ */
85108function get_plugins ( tree ) : Array < string > {
86109
87110 let plugins = [ ]
@@ -95,6 +118,11 @@ function get_plugins(tree): Array<string> {
95118 return plugins
96119}
97120
121+ /**
122+ * Gets the list of highlight themes currently available in the GitHub repo
123+ * @param tree Array of repo nodes containing the files' paths/names and urls
124+ * @returns The list of highlight themes' names
125+ */
98126function get_highlight_themes ( tree ) : Array < string > {
99127
100128 let highlight_themes = [ ]
@@ -108,6 +136,11 @@ function get_highlight_themes(tree): Array<string> {
108136 return highlight_themes
109137}
110138
139+ /**
140+ * Guides the user with a set of questions in order to build the presentation
141+ * and saves the last chosen configuration
142+ * @param markdown_file The name of the markdown file to be used in the presentation generation
143+ */
111144function ask_user ( markdown_file : string ) {
112145 if ( ! fs . existsSync ( cache_dir ) )
113146 fs . mkdirSync ( cache_dir , { recursive : true } )
@@ -129,9 +162,12 @@ function ask_user(markdown_file: string) {
129162
130163 download_files ( fonts , tree )
131164
132- let plugins = get_plugins ( tree )
165+ let plugins = get_plugins ( tree ) . filter ( item => item != "markdown.js" )
133166
134- new MultipleChoiceQuestion ( "plugins" , "Which plugins do you want to include?" , plugins ) . create_question ( ( a ) => {
167+ new MultipleChoiceQuestion ( "plugins" , "Which plugins do you want to include (besides markdown.js)?" , plugins ) . create_question ( ( a ) => {
168+
169+ a . plugins . push ( "markdown.js" )
170+
135171 user_config . plugins = a . plugins
136172 download_files ( a . plugins , tree )
137173
@@ -157,6 +193,10 @@ function ask_user(markdown_file: string) {
157193 } )
158194}
159195
196+ /**
197+ * Asks the user for the markdown configuration questions and builds the presentation
198+ * @param markdown_file The name of the markdown file to be used in the presentation generation
199+ */
160200function generate_slides ( markdown_file : string ) {
161201
162202 new MultipleInputQuestions (
@@ -224,7 +264,7 @@ function main(): number {
224264| |
225265| revdown-cli |
226266| |
227- | v1.0.0 |
267+ | v1.0.1 |
228268---------------------------------` ) )
229269
230270 if ( ! fs . existsSync ( user_dir + "user.json" ) ) {
@@ -253,7 +293,7 @@ function main(): number {
253293 return 0
254294 }
255295
256- err ( "Usage: revdown mymarkdownfile.md" , process . argv . length )
296+ err ( "Usage: revdown mymarkdownfile.md" )
257297
258298 return 1
259299}
0 commit comments