Fossil SCM

Add --html option to the 'test-all-help' command.

mistachkin 2016-09-23 17:10 trunk
Commit 1763f2879ca85cb412a34fa3d5e2dcae21ecfdb1
1 file changed +63 -44
+63 -44
--- src/dispatch.c
+++ src/dispatch.c
@@ -59,11 +59,11 @@
5959
** of CmdOrPage objects that defines all available commands and webpages
6060
** known to Fossil.
6161
**
6262
** The entries in aCommand[] are in sorted order by name. Since webpage names
6363
** always begin with "/", all webpage names occur first. The page_index.h file
64
-** also sets the FOSSIL_FIRST_CMD macro to be the *approximate* index
64
+** also sets the FOSSIL_FIRST_CMD macro to be the *approximate* index
6565
** in aCommand[] of the first command entry. FOSSIL_FIRST_CMD might be
6666
** slightly too low, and so the range FOSSIL_FIRST_CMD...MX_COMMAND might
6767
** contain a few webpage entries at the beginning.
6868
**
6969
** The page_index.h file is generated by the mkindex program which scans all
@@ -134,53 +134,10 @@
134134
blob_appendf(pList, " %s", aCommand[i].zName);
135135
}
136136
}
137137
}
138138
139
-
140
-/*
141
-** COMMAND: test-all-help
142
-**
143
-** Usage: %fossil test-all-help ?OPTIONS?
144
-**
145
-** Show help text for commands and pages. Useful for proof-reading.
146
-** Defaults to just the CLI commands. Specify --www to see only the
147
-** web pages, or --everything to see both commands and pages.
148
-**
149
-** Options:
150
-** -e|--everything Show all commands and pages.
151
-** -t|--test Include test- commands
152
-** -w|--www Show WWW pages.
153
-*/
154
-void test_all_help_cmd(void){
155
- int i;
156
- int mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER;
157
-
158
- if( find_option("www","w",0) ){
159
- mask = CMDFLAG_WEBPAGE;
160
- }
161
- if( find_option("everything","e",0) ){
162
- mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE;
163
- }
164
- if( find_option("test","t",0) ){
165
- mask |= CMDFLAG_TEST;
166
- }
167
- fossil_print("Help text for:\n");
168
- if( mask & CMDFLAG_1ST_TIER ) fossil_print(" * Commands\n");
169
- if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
170
- if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
171
- if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
172
- fossil_print("---\n");
173
- for(i=0; i<MX_COMMAND; i++){
174
- if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
175
- fossil_print("# %s\n", aCommand[i].zName);
176
- fossil_print("%s\n\n", aCommand[i].zHelp);
177
- }
178
- fossil_print("---\n");
179
- version_cmd();
180
-}
181
-
182139
/*
183140
** Attempt to reformat plain-text help into HTML for display on a webpage.
184141
**
185142
** The HTML output is appended to Blob pHtml, which should already be
186143
** initialized.
@@ -202,10 +159,72 @@
202159
*d = 0;
203160
204161
blob_appendf(pHtml, "<pre>\n%h\n</pre>\n", z);
205162
fossil_free(z);
206163
}
164
+
165
+/*
166
+** COMMAND: test-all-help
167
+**
168
+** Usage: %fossil test-all-help ?OPTIONS?
169
+**
170
+** Show help text for commands and pages. Useful for proof-reading.
171
+** Defaults to just the CLI commands. Specify --www to see only the
172
+** web pages, or --everything to see both commands and pages.
173
+**
174
+** Options:
175
+** -e|--everything Show all commands and pages.
176
+** -t|--test Include test- commands
177
+** -w|--www Show WWW pages.
178
+** -h|--html Transform output to HTML.
179
+*/
180
+void test_all_help_cmd(void){
181
+ int i;
182
+ int mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER;
183
+ int useHtml = find_option("html","h",0)!=0;
184
+
185
+ if( find_option("www","w",0) ){
186
+ mask = CMDFLAG_WEBPAGE;
187
+ }
188
+ if( find_option("everything","e",0) ){
189
+ mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE;
190
+ }
191
+ if( find_option("test","t",0) ){
192
+ mask |= CMDFLAG_TEST;
193
+ }
194
+ if( useHtml ) fossil_print("<!--\n");
195
+ fossil_print("Help text for:\n");
196
+ if( mask & CMDFLAG_1ST_TIER ) fossil_print(" * Commands\n");
197
+ if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
198
+ if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
199
+ if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
200
+ if( useHtml ){
201
+ fossil_print("-->\n");
202
+ fossil_print("<!-- start_all_help -->\n");
203
+ }else{
204
+ fossil_print("---\n");
205
+ }
206
+ for(i=0; i<MX_COMMAND; i++){
207
+ if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
208
+ fossil_print("# %s\n", aCommand[i].zName);
209
+ if( useHtml ){
210
+ Blob html;
211
+ blob_zero(&html);
212
+ help_to_html(aCommand[i].zHelp, &html);
213
+ fossil_print("%s\n\n", blob_str(&html));
214
+ blob_reset(&html);
215
+ }else{
216
+ fossil_print("%s\n\n", aCommand[i].zHelp);
217
+ }
218
+ }
219
+ if( useHtml ){
220
+ fossil_print("<!-- end_all_help -->\n");
221
+ }else{
222
+ fossil_print("---\n");
223
+ }
224
+ version_cmd();
225
+}
207226
208227
/*
209228
** WEBPAGE: help
210229
** URL: /help?name=CMD
211230
**
212231
--- src/dispatch.c
+++ src/dispatch.c
@@ -59,11 +59,11 @@
59 ** of CmdOrPage objects that defines all available commands and webpages
60 ** known to Fossil.
61 **
62 ** The entries in aCommand[] are in sorted order by name. Since webpage names
63 ** always begin with "/", all webpage names occur first. The page_index.h file
64 ** also sets the FOSSIL_FIRST_CMD macro to be the *approximate* index
65 ** in aCommand[] of the first command entry. FOSSIL_FIRST_CMD might be
66 ** slightly too low, and so the range FOSSIL_FIRST_CMD...MX_COMMAND might
67 ** contain a few webpage entries at the beginning.
68 **
69 ** The page_index.h file is generated by the mkindex program which scans all
@@ -134,53 +134,10 @@
134 blob_appendf(pList, " %s", aCommand[i].zName);
135 }
136 }
137 }
138
139
140 /*
141 ** COMMAND: test-all-help
142 **
143 ** Usage: %fossil test-all-help ?OPTIONS?
144 **
145 ** Show help text for commands and pages. Useful for proof-reading.
146 ** Defaults to just the CLI commands. Specify --www to see only the
147 ** web pages, or --everything to see both commands and pages.
148 **
149 ** Options:
150 ** -e|--everything Show all commands and pages.
151 ** -t|--test Include test- commands
152 ** -w|--www Show WWW pages.
153 */
154 void test_all_help_cmd(void){
155 int i;
156 int mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER;
157
158 if( find_option("www","w",0) ){
159 mask = CMDFLAG_WEBPAGE;
160 }
161 if( find_option("everything","e",0) ){
162 mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE;
163 }
164 if( find_option("test","t",0) ){
165 mask |= CMDFLAG_TEST;
166 }
167 fossil_print("Help text for:\n");
168 if( mask & CMDFLAG_1ST_TIER ) fossil_print(" * Commands\n");
169 if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
170 if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
171 if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
172 fossil_print("---\n");
173 for(i=0; i<MX_COMMAND; i++){
174 if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
175 fossil_print("# %s\n", aCommand[i].zName);
176 fossil_print("%s\n\n", aCommand[i].zHelp);
177 }
178 fossil_print("---\n");
179 version_cmd();
180 }
181
182 /*
183 ** Attempt to reformat plain-text help into HTML for display on a webpage.
184 **
185 ** The HTML output is appended to Blob pHtml, which should already be
186 ** initialized.
@@ -202,10 +159,72 @@
202 *d = 0;
203
204 blob_appendf(pHtml, "<pre>\n%h\n</pre>\n", z);
205 fossil_free(z);
206 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
208 /*
209 ** WEBPAGE: help
210 ** URL: /help?name=CMD
211 **
212
--- src/dispatch.c
+++ src/dispatch.c
@@ -59,11 +59,11 @@
59 ** of CmdOrPage objects that defines all available commands and webpages
60 ** known to Fossil.
61 **
62 ** The entries in aCommand[] are in sorted order by name. Since webpage names
63 ** always begin with "/", all webpage names occur first. The page_index.h file
64 ** also sets the FOSSIL_FIRST_CMD macro to be the *approximate* index
65 ** in aCommand[] of the first command entry. FOSSIL_FIRST_CMD might be
66 ** slightly too low, and so the range FOSSIL_FIRST_CMD...MX_COMMAND might
67 ** contain a few webpage entries at the beginning.
68 **
69 ** The page_index.h file is generated by the mkindex program which scans all
@@ -134,53 +134,10 @@
134 blob_appendf(pList, " %s", aCommand[i].zName);
135 }
136 }
137 }
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139 /*
140 ** Attempt to reformat plain-text help into HTML for display on a webpage.
141 **
142 ** The HTML output is appended to Blob pHtml, which should already be
143 ** initialized.
@@ -202,10 +159,72 @@
159 *d = 0;
160
161 blob_appendf(pHtml, "<pre>\n%h\n</pre>\n", z);
162 fossil_free(z);
163 }
164
165 /*
166 ** COMMAND: test-all-help
167 **
168 ** Usage: %fossil test-all-help ?OPTIONS?
169 **
170 ** Show help text for commands and pages. Useful for proof-reading.
171 ** Defaults to just the CLI commands. Specify --www to see only the
172 ** web pages, or --everything to see both commands and pages.
173 **
174 ** Options:
175 ** -e|--everything Show all commands and pages.
176 ** -t|--test Include test- commands
177 ** -w|--www Show WWW pages.
178 ** -h|--html Transform output to HTML.
179 */
180 void test_all_help_cmd(void){
181 int i;
182 int mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER;
183 int useHtml = find_option("html","h",0)!=0;
184
185 if( find_option("www","w",0) ){
186 mask = CMDFLAG_WEBPAGE;
187 }
188 if( find_option("everything","e",0) ){
189 mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE;
190 }
191 if( find_option("test","t",0) ){
192 mask |= CMDFLAG_TEST;
193 }
194 if( useHtml ) fossil_print("<!--\n");
195 fossil_print("Help text for:\n");
196 if( mask & CMDFLAG_1ST_TIER ) fossil_print(" * Commands\n");
197 if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
198 if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
199 if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
200 if( useHtml ){
201 fossil_print("-->\n");
202 fossil_print("<!-- start_all_help -->\n");
203 }else{
204 fossil_print("---\n");
205 }
206 for(i=0; i<MX_COMMAND; i++){
207 if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
208 fossil_print("# %s\n", aCommand[i].zName);
209 if( useHtml ){
210 Blob html;
211 blob_zero(&html);
212 help_to_html(aCommand[i].zHelp, &html);
213 fossil_print("%s\n\n", blob_str(&html));
214 blob_reset(&html);
215 }else{
216 fossil_print("%s\n\n", aCommand[i].zHelp);
217 }
218 }
219 if( useHtml ){
220 fossil_print("<!-- end_all_help -->\n");
221 }else{
222 fossil_print("---\n");
223 }
224 version_cmd();
225 }
226
227 /*
228 ** WEBPAGE: help
229 ** URL: /help?name=CMD
230 **
231

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button