diff --git a/tools/Docgen/Options.cs b/tools/Docgen/Options.cs index 4f61e5c..eab7a3b 100644 --- a/tools/Docgen/Options.cs +++ b/tools/Docgen/Options.cs @@ -15,6 +15,7 @@ public class Options public string TargetNamespace; public readonly List NamespaceFilters = new List(); + public string ApiPath; public bool ShouldShowHelp; public string Help; @@ -45,6 +46,11 @@ public static void ParseOptions(string[] args) "A regex used to filter out namespaces that you don't want to generate docs for.", s => options.NamespaceFilters.Add(new Regex(s)) }, + { + "api-path=", + "REQUIRED: The path from the urlRoot to the api directory.", + s => options.ApiPath = s + }, { "h|help", "Show help", @@ -58,6 +64,12 @@ public static void ParseOptions(string[] args) { throw new ArgumentException("Failed to provide required argument 'target-namespace'"); } + + if (options.ApiPath == null) + { + throw new ArgumentException("Failed to provide required argument 'api-path'"); + } + using (var stringWriter = new StringWriter()) { diff --git a/tools/Docgen/Utils/Formatting.cs b/tools/Docgen/Utils/Formatting.cs index a12231e..fbff059 100644 --- a/tools/Docgen/Utils/Formatting.cs +++ b/tools/Docgen/Utils/Formatting.cs @@ -16,7 +16,8 @@ public static string CompoundNameToTypeName(string compoundName) public static string CompoundNameToRelativePath(string compoundName) { - var markdownSplitPath = compoundName.Replace("Improbable::Gdk::", "").Split("::") + var namespac = Options.Instance.TargetNamespace.Replace(".", "::") + "::"; + var markdownSplitPath = compoundName.Replace(namespac, "").Split("::") .Select(CamelCaseToKebabCase); return string.Join('/', markdownSplitPath); @@ -25,7 +26,7 @@ public static string CompoundNameToRelativePath(string compoundName) public static string CompoundNameToImprobadocLink(string compoundName) { var markdownName = CompoundNameToRelativePath(compoundName); - return $"{{{{urlRoot}}}}/content/api/{markdownName}"; + return $"{{{{urlRoot}}}}/{Options.Instance.ApiPath}/{markdownName}"; } public static string FixGenericBrackets(string str)