|
|
@@ -1,4 +1,10 @@
|
|
|
|
|
|
+/* TODO:
|
|
|
+* Create syntax for automatically including links to outmost documents in a specified folder.
|
|
|
+* Create syntax for automatically documenting methods in specified headers based on above comments.
|
|
|
+ Follow include "", but not include <> when listing types.
|
|
|
+*/
|
|
|
+
|
|
|
#include "../../Source/DFPSR/includeFramework.h"
|
|
|
|
|
|
using namespace dsr;
|
|
|
@@ -6,7 +12,7 @@ using namespace dsr;
|
|
|
// This program is only for maintaining the library's documentation,
|
|
|
// so it's okay to use features specific to the Linux operating system.
|
|
|
|
|
|
-String ResourceFolderPath;
|
|
|
+String resourceFolderPath;
|
|
|
|
|
|
bool string_beginsWith(const ReadableString &a, const ReadableString &b) {
|
|
|
return string_caseInsensitiveMatch(string_before(a, string_length(b)), b);
|
|
|
@@ -96,7 +102,7 @@ void processContent(String &target, String content) {
|
|
|
}
|
|
|
|
|
|
String generateHtml(String content) {
|
|
|
- String style = string_load(ResourceFolderPath + U"Default.css");
|
|
|
+ String style = string_load(file_combinePaths(resourceFolderPath, U"Default.css"));
|
|
|
String result = U"<!DOCTYPE html> <HTML lang=en> <HEAD> <STYLE>\n";
|
|
|
string_append(result, style);
|
|
|
string_append(result, U"</STYLE> </HEAD> <BODY>\n");
|
|
|
@@ -108,20 +114,42 @@ String generateHtml(String content) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-int main(int argn, char **argv) {
|
|
|
- if (argn != 4) {
|
|
|
- printText(U"The generator needs filenames for target!\n");
|
|
|
- return 1;
|
|
|
+static ReadableString getExtensionless(const String& filename) {
|
|
|
+ int lastDotIndex = string_findLast(filename, U'.');
|
|
|
+ if (lastDotIndex != -1) {
|
|
|
+ return string_removeOuterWhiteSpace(string_before(filename, lastDotIndex));
|
|
|
+ } else {
|
|
|
+ return U"?";
|
|
|
}
|
|
|
- String SourceFilePath = argv[1];
|
|
|
- String TargetFilePath = argv[2];
|
|
|
- ResourceFolderPath = argv[3];
|
|
|
+}
|
|
|
+
|
|
|
+void processFolder(const ReadableString& sourceFolderPath, const ReadableString& targetFolderPath) {
|
|
|
+ file_getFolderContent(sourceFolderPath, [targetFolderPath](const ReadableString& sourcePath, const ReadableString& entryName, EntryType entryType) {
|
|
|
+ printText("* Entry: ", entryName, " as ", entryType, "\n");
|
|
|
+ if (entryType == EntryType::Folder) {
|
|
|
+ // TODO: Create new output folders if needed for nested output.
|
|
|
+ //processFolder(sourcePath, file_combinePaths(targetFolderPath, entryName));
|
|
|
+ } else if (entryType == EntryType::File) {
|
|
|
+ ReadableString extensionless = getExtensionless(entryName);
|
|
|
+ String targetPath = file_combinePaths(targetFolderPath, extensionless + U".html");
|
|
|
+ printText(U"Generating ", targetPath, U" from ", sourcePath, U" using the style ", resourceFolderPath, U"\n");
|
|
|
+ String content = string_load(sourcePath);
|
|
|
+ String result = generateHtml(content);
|
|
|
+ string_save(file_combinePaths(targetFolderPath, targetPath), result);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
- printText(U"Generating ", TargetFilePath, U" from ", SourceFilePath, U" using the style", ResourceFolderPath, U"\n");
|
|
|
-
|
|
|
- String content = string_load(SourceFilePath);
|
|
|
- String result = generateHtml(content);
|
|
|
- string_save(TargetFilePath, result);
|
|
|
- printText(U"Done\n");
|
|
|
- return 0;
|
|
|
+DSR_MAIN_CALLER(dsrMain)
|
|
|
+void dsrMain(List<String> args) {
|
|
|
+ if (args.length() != 4) {
|
|
|
+ printText(U"The generator needs input, output and resource folder paths as three arguments!\n");
|
|
|
+ } else {
|
|
|
+ String sourceFolderPath = file_getAbsolutePath(args[1]);
|
|
|
+ String targetFolderPath = file_getAbsolutePath(args[2]);
|
|
|
+ resourceFolderPath = args[3];
|
|
|
+ printText(U"Processing ", targetFolderPath, U" from ", sourceFolderPath, U" using the style ", resourceFolderPath, U"\n");
|
|
|
+ processFolder(sourceFolderPath, targetFolderPath);
|
|
|
+ printText(U"Done\n");
|
|
|
+ }
|
|
|
}
|