Skip to content

Commit

Permalink
more hard code strings removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Brynes committed Jan 7, 2019
1 parent ff6d203 commit 916177c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions tools/Docgen/Options.cs
Expand Up @@ -15,6 +15,7 @@ public class Options

public string TargetNamespace;
public readonly List<Regex> NamespaceFilters = new List<Regex>();
public string ApiPath;

public bool ShouldShowHelp;
public string Help;
Expand Down Expand Up @@ -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",
Expand All @@ -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())
{
Expand Down
5 changes: 3 additions & 2 deletions tools/Docgen/Utils/Formatting.cs
Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit 916177c

Please sign in to comment.