Changeset 8
- Timestamp:
- 11/06/05 03:04:21 (3 years ago)
- Files:
-
- trunk/src/tutorials/converttowiki/categories/ArraysCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/CommonErrorsCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/DelegateCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/DflCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/ForeachCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/FunctionLiteralsCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/HandlingErrorsCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/KeywordsCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/MangoCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/OperatorOverloadingCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/StandardLibraryCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/SwitchCaseCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/TemplatesCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/TutorialAdvanced.html (added)
- trunk/src/tutorials/converttowiki/categories/TutorialFundamentals.html (added)
- trunk/src/tutorials/converttowiki/categories/TutorialIntermediate.html (added)
- trunk/src/tutorials/converttowiki/categories/VersioningCategory.html (added)
- trunk/src/tutorials/converttowiki/categories/WindowsGuiCategory.html (added)
- trunk/src/tutorials/converttowiki/convertToWiki.d (modified) (11 diffs)
- trunk/src/tutorials/converttowiki/names.d (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/tutorials/converttowiki/convertToWiki.d
r7 r8 20 20 const char[] begTopicMarker = `<li><a href="#topic`; 21 21 const char[] endCatNameMarker = " ("; 22 const char[] endPhase2 = `<div class="app" style="margin-left: 0.5em;">`; 23 const char[] begTopicListMarker = `<li id="topic`; 24 const char[] endTopicListMarker = `</a></li></ul>`; 25 26 const char[] begExampleListMarker = `<li><a href="#ex`; 27 const char[] endExampleListMarker = `</a></li>`; 28 29 22 30 23 31 … … 46 54 int endPos; 47 55 48 bit done; 56 int topicBegPos; 57 int topicEndPos; 58 59 // bit done; 49 60 50 61 … … 57 68 writefln("Please specify the input file and output path at the commandline."); 58 69 70 71 /* *** Read Entire Input File *** */ 59 72 60 73 File inFile = new File(inputFile); … … 64 77 65 78 79 /* *** Create Index File *** */ 80 66 81 begPos = find(inStr, begCategoriesMarker ); 67 82 if(begPos < 0) … … 80 95 { 81 96 inStr = inStr[begPos + begTopicMarker.length .. $]; 82 endPos = find(inStr, endCategoriesMarker);97 //endPos = find(inStr, endCategoriesMarker); 83 98 84 99 begPos = find(inStr, `>`); … … 114 129 } 115 130 116 117 118 131 File outFile = new File(outputPath ~ "index.html", FileMode.OutNew); 119 132 … … 134 147 135 148 136 137 /+ 138 // This code isn't ready yet. 139 140 /* For each example */ 141 142 143 { 149 /* *** Create Category Files *** */ 150 151 debug writefln("\n***Create Category Files ***"); 152 153 while(topicBegPos >= 0) /* loop for each category */ 154 { 155 wikiExampleNames.length = 0; 156 157 topicBegPos = find(inStr, begTopicListMarker); 158 if(topicBegPos < 0) 159 { 160 writefln("Error: Example name not found!"); 161 assert(0); 162 } 163 inStr = inStr[topicBegPos + 1 .. $]; 164 165 begPos = find(inStr, `>`); 166 if(begPos < 0) 167 { 168 writefln("Error: Category name not found!"); 169 assert(0); 170 } 171 inStr = inStr[begPos + 1 .. $]; 172 173 midPos = find(inStr, `</li>`); 174 oldCategoryName = inStr[0..midPos]; 175 debug writefln("Found old category name: " ~ oldCategoryName); 176 wikiCategory = wikiCategoryName(oldCategoryName); 177 debug writefln("Found new category: " ~ wikiCategory); 178 topicEndPos = find(inStr, endPhase2); //endTopicListMarker); 179 180 181 begPos = find(inStr, begExampleListMarker); 182 183 while(begPos >= 0) /* loop through the examples */ 184 { 185 if(begPos < 0) 186 { 187 writefln("Error: Example name not found!"); 188 assert(0); 189 } 190 inStr = inStr[begPos + begExampleListMarker.length .. $]; 191 192 begPos = find(inStr, `>`); 193 if(begPos < 0) 194 { 195 writefln("Error: Example name not found!"); 196 assert(0); 197 } 198 inStr = inStr[begPos + 1 .. $]; 199 endPos = find(inStr, endExampleListMarker ); 200 if(endPos < 0) 201 { 202 writefln("Error: Example name ending not found!"); 203 assert(0); 204 } 205 oldExampleName = inStr[0..endPos]; 206 207 wikiExample = wikiExampleName(oldCategoryName, oldExampleName); 208 wikiExampleNames ~= wikiExample; 209 210 begPos = find(inStr, begExampleListMarker); 211 endPos = find(inStr, endTopicListMarker); //endExampleListMarker); 212 213 if(endPos < begPos) begPos = -1; 214 } 215 144 216 File outFile = new File(outputPath ~ wikiCategory ~ ".html", FileMode.OutNew); 145 217 146 218 outFile.writeLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); 147 219 outFile.writeLine("<html><head><title>" ~ args[1] ~ "</title>"); … … 149 221 outFile.writeLine("</head>"); 150 222 151 outFile.writeLine(`<body><pre> <hr/>= ` ~ oldCategoryName ~ ` =<br/><a href=#"examples"<br/>`);152 153 outFile.writeLine(`<hr id="` ~ wikiCategory ~ `" />= ` ~ oldCategoryName ~ " =<br/><br/>");223 outFile.writeLine(`<body><pre>= ` ~ oldCategoryName ~ ` =<br/>`); 224 225 //outFile.writeLine(`<hr id="` ~ wikiCategory ~ `" />= ` ~ oldCategoryName ~ " =<br/>"); 154 226 foreach(char[] we; wikiExampleNames) 155 outFile.writeLine(` * < #"` ~ we ~ `">` ~ we ~ `</a><br/>`);227 outFile.writeLine(` * <a href="` ~ we ~ `".html>` ~ we ~ `</a>`); 156 228 157 229 outFile.writeLine("</pre></body></html>"); 158 230 outFile.close(); 159 } 160 +/ 161 162 231 232 topicBegPos = find(inStr, begTopicListMarker); 233 topicEndPos = find(inStr, endPhase2); //endTopicListMarker); 234 235 if(topicEndPos < topicBegPos) topicBegPos = -1; 236 } 163 237 164 238 /+ 165 239 166 /* Create Category File */ 167 168 169 wikiExampleNames.length = 0; 170 240 // This code isn't ready yet. 241 242 243 244 debug writefln("\n***Create Example Files ***"); 245 246 /* *** Create Example Files *** */ 171 247 172 248 while(stillMoreExamples) /* for each example: */ … … 219 295 wikiExample = wikiExampleName(oldCategoryName, oldExampleName); 220 296 221 wikiExampleNames ~= wikiExample 222 223 outFile.writeLine(`<hr id="` ~ wikiExample ~ `"/>= ` ~ oldExampleName ~ " =<br/>"); 297 298 299 300 File outFile = new File(outputPath ~ wikiCategory ~ ".html", FileMode.OutNew); 301 302 outFile.writeLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); 303 outFile.writeLine("<html><head><title>" ~ args[1] ~ "</title>"); 304 outFile.writeLine(`<link rel="stylesheet" href="` ~ cssFile ~ `"/>`); 305 outFile.writeLine("</head>"); 306 307 outFile.writeLine(`<body><pre>= ` ~ oldExampleName ~ ` =<br/>`); 308 309 //outFile.writeLine(`<hr id="` ~ wikiExample ~ `"/>= ` ~ oldExampleName ~ " =<br/>"); 224 310 outFile.writeLine("''Part of'' " ~ wikiCategory ~ "<br/>"); 225 311 … … 229 315 outFile.writeLine("== Example ==<br/>"); 230 316 outFile.writeLine("{{{"); 231 outFile.writeLine("#!d ");317 outFile.writeLine("#!d</pre>"); 232 318 233 319 //outFile.writeLine("<code>"); … … 245 331 246 332 outFile.writeLine("}}}"); 333 334 335 336 outFile.writeLine("</body></html>"); 337 outFile.close(); 338 247 339 248 340 if(begPos == 0 && begPos > endPos) done = true; trunk/src/tutorials/converttowiki/names.d
r7 r8 118 118 case "Assertions": s = "AssertionsExample"; break; 119 119 case "Unittests": s = "UnittestsExample"; break; 120 case "Getch/Getchar": s = " "; break;121 default: writefln("Unknown example: % ", e); assert(0);120 case "Getch/Getchar": s = "GetchGetcharExample"; break; 121 default: writefln("Unknown example: %s", e); assert(0); 122 122 } break; 123 123 … … 139 139 case "Runtime Type Information (RTTI)": s = "RuntimeTypeInformationExample"; break; 140 140 case "Statistics": s = "StatisticsExample"; break; 141 default: writefln("Unknown example: % ", e); assert(0);141 default: writefln("Unknown example: %s", e); assert(0); 142 142 } break; 143 143 … … 153 153 case "Meta tags (__FILE__, __LINE__, etc.)": s = "MetaTagsExample"; break; 154 154 case "uudecode": s = "UudecodeExample"; break; 155 default: writefln("Unknown example: % ", e); assert(0);155 default: writefln("Unknown example: %s", e); assert(0); 156 156 } break; 157 157 … … 167 167 case "goto": s = "GotoExample"; break; 168 168 case "return": s = "ReturnExample"; break; 169 default: writefln("Unknown example: % ", e); assert(0);169 default: writefln("Unknown example: %s", e); assert(0); 170 170 } break; 171 171 … … 178 178 case "Returning Arrays from Functions": s = "ReturningArraysFromFunctionsExample"; break; 179 179 case "Using char[][] args": s = "UsingCharArrayArgumentsExample"; break; 180 default: writefln("Unknown example: % ", e); assert(0);180 default: writefln("Unknown example: %s", e); assert(0); 181 181 } break; 182 182 … … 187 187 case "Using Objects": s = "UsingObjectsExample"; break; 188 188 case "Printing a Slice from a String": s = "PrintingSliceFromStringExample"; break; 189 default: writefln("Unknown example: % ", e); assert(0);189 default: writefln("Unknown example: %s", e); assert(0); 190 190 } break; 191 191 … … 195 195 case "DelegateTest.d": s = "UsingDelegatesWithinObjectsExample"; break; 196 196 case "Delegates": s = "UsingDelegateInsteadOfInterfaceExample"; break; 197 case "Proper creation & use of stack delegates": s = "UsingStackDelegatesExample"; break;197 case "Proper creation & use of stack delegates": s = "UsingStackDelegatesExample"; break; 198 198 case "Don't Return a Stack Delegate": s = "DontReturnStackDelegateExample"; break; 199 199 case "Copyable stack delegates, implemented with structs and classes": s = "CopyableStackDelegatesWithStructsAndClassesExample"; break; … … 201 201 case "Delegate 1": s = "DelegateNonStaticNestedFunctionExample"; break; 202 202 case "Delegate 2": s = "IntFunctionDelegateExample"; break; 203 default: writefln("Unknown example: % ", e); assert(0);203 default: writefln("Unknown example: %s", e); assert(0); 204 204 } break; 205 205 … … 213 213 case "Foreach with key and value pairs": s = "ForeachKeyValuePairsExample"; break; 214 214 case "Associative array of strings": s = "ForeachStringArrExample"; break; 215 default: writefln("Unknown example: % ", e); assert(0);215 default: writefln("Unknown example: %s", e); assert(0); 216 216 } break; 217 217 … … 221 221 case "Function Literal Assignment": s = "FunctionLiteralAssignExample"; break; 222 222 case "Function Literal / Anonymous Function": s = "AnonymousFunctionExample"; break; 223 default: writefln("Unknown example: % ", e); assert(0);223 default: writefln("Unknown example: %s", e); assert(0); 224 224 } break; 225 225 … … 229 229 case "DBC: basic design by contract": s = "DesignByContractExample"; break; 230 230 case "Try/Catch/Finally": s = "TryCatchFinallyExample"; break; 231 default: writefln("Unknown example: % ", e); assert(0);231 default: writefln("Unknown example: %s", e); assert(0); 232 232 } break; 233 233 … … 239 239 case "opCall": s = "OpCallExample"; break; 240 240 case "Byte.d": s = "ByteOperatingOverloadExample"; break; 241 default: writefln("Unknown example: % ", e); assert(0);241 default: writefln("Unknown example: %s", e); assert(0); 242 242 } break; 243 243 … … 245 245 switch(e) 246 246 { 247 case "Switch-Case Construct": s = " "; break;248 case "The Twelve Days of Christmas": s = " "; break;247 case "Switch-Case Construct": s = "SwitchCaseExample"; break; 248 case "The Twelve Days of Christmas": s = "TwelveDaysOfChristmasExampleOne"; break; 249 249 case "The Twelve Days of Christmas (Reprise)": s = "TwelveDaysOfChristmasExampleTwo"; break; 250 default: writefln("Unknown example: % ", e); assert(0);250 default: writefln("Unknown example: %s", e); assert(0); 251 251 } break; 252 252 … … 264 264 case "Variable Arguments": s = "TemplateVariableArgumentsExample"; break; 265 265 case "Template RTTI": s = "TemplateRttiExample"; break; 266 default: writefln("Unknown example: % ", e); assert(0);266 default: writefln("Unknown example: %s", e); assert(0); 267 267 } break; 268 268 … … 273 273 case "Using versions to store multiple programs in one file": s = "UsingVersionsToStoreMultipleProgramInOneFileExample"; break; 274 274 case "Compile time versioning": s = "CompileTimeVersioningExample"; break; 275 default: writefln("Unknown example: % ", e); assert(0);275 default: writefln("Unknown example: %s", e); assert(0); 276 276 } break; 277 277 … … 286 286 case "Checkboxes": s = "DflCheckboxesExample"; break; 287 287 case "Controls": s = "DflControlsExample"; break; 288 default: writefln("Unknown example: % ", e); assert(0);288 default: writefln("Unknown example: %s", e); assert(0); 289 289 } break; 290 290 … … 293 293 { 294 294 case "I/O with Mango": s = "IoWithMangoExample"; break; 295 default: writefln("Unknown example: % ", e); assert(0);295 default: writefln("Unknown example: %s", e); assert(0); 296 296 } break; 297 297 … … 321 321 case "Zlib": s = "ZlibExample"; break; 322 322 case "Unzip using std.zip": s = "UnzipUsingStdZipExample"; break; 323 default: writefln("Unknown example: % ", e); assert(0);323 default: writefln("Unknown example: %s", e); assert(0); 324 324 } break; 325 325 … … 330 330 case "TreeView": s = "TreeViewExample"; break; 331 331 case "MiniCalc - RestorePosition": s = "MiniCalcRestorePositionExample"; break; 332 default: writefln("Unknown example: % ", e); assert(0);333 } break; 334 default: writefln("Unknown category: % ",e); assert(0);332 default: writefln("Unknown example: %s", e); assert(0); 333 } break; 334 default: writefln("Unknown category: %s", oldCategoryName); assert(0); 335 335 } 336 336 return s;
