static void Main(string[] args) { const string rhinocommonPath = @"C:\dev\github\mcneel\rhino\src4\DotNetSDK\rhinocommon\dotnet"; Console.WriteLine("[BEGIN PARSE]"); Console.ForegroundColor = ConsoleColor.DarkGreen; ClassBuilder.BuildClassDictionary(rhinocommonPath); Console.ResetColor(); Console.WriteLine("[END PARSE]"); // just do a small number of classes to get started string[] filter = new string[] { ".Mesh", ".Brep", ".BrepFace", ".Curve", ".BezierCurve", ".Extrusion", ".NurbsCurve", ".Intersection", ".AreaMassProperties", ".VolumeMassProperties" }; Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Writing javascript client"); var js = new JavascriptClient(); js.Write(ClassBuilder.AllClasses, "compute.rhino3d.js", filter); Console.WriteLine("Writing python client"); var py = new PythonClient(); py.Write(ClassBuilder.AllClasses, "", filter); Console.WriteLine("Writing C# client"); var cs = new DotNetClient(); cs.Write(ClassBuilder.AllClasses, "RhinoCompute.cs", filter); Console.ResetColor(); }
static void Main(string[] args) { var rootDir = GetRepoRootDirectory(); var distDir = Path.Combine(rootDir, "dist"); // destination for generated client code var rhinocommonPath = Path.Combine("rhino3dm", "src", "dotnet"); if (!Directory.Exists(rhinocommonPath)) { throw new InvalidOperationException($"RhinoCommon directory not found! ({rhinocommonPath})"); } Console.WriteLine("[BEGIN PARSE]"); Console.ForegroundColor = ConsoleColor.DarkGreen; ClassBuilder.BuildClassDictionary(rhinocommonPath); Console.ResetColor(); Console.WriteLine("[END PARSE]"); string[] filter = new string[] { ".AreaMassProperties", ".BezierCurve", ".Brep", ".BrepFace", ".Curve", ".Extrusion", ".GeometryBase", ".Intersection", ".Mesh", ".NurbsCurve", ".NurbsSurface", ".SubD", ".Surface", ".VolumeMassProperties" }; var classes = ClassBuilder.FilteredList(ClassBuilder.AllClasses, filter); Console.ForegroundColor = ConsoleColor.Blue; /* --- JavaScript --- */ Console.WriteLine("Writing javascript client"); string jsDir = Path.Combine(distDir, "javascript"); Console.WriteLine(jsDir); Directory.CreateDirectory(jsDir); var js = new JavascriptClient(false); js.Write(ClassBuilder.AllClasses, Path.Combine(jsDir, "compute.rhino3d.js"), filter); var jsm = new JavascriptClient(true); jsm.Write(ClassBuilder.AllClasses, Path.Combine(jsDir, "compute.rhino3d.module.js"), filter); Console.WriteLine("Writing javascript docs"); RstClient.WriteJavascriptDocs(classes, distDir); /* ----- Python ----- */ Console.WriteLine("Writing python client"); string pyDir = Path.Combine(distDir, "python"); Console.WriteLine(pyDir); Directory.CreateDirectory(pyDir); var py = new PythonClient(); py.Write(ClassBuilder.AllClasses, pyDir, filter); Console.WriteLine("Writing python docs"); RstClient.WritePythonDocs(classes, distDir); /* ------- C# ------- */ Console.WriteLine("Writing C# client"); var csDir = Path.Combine(distDir, "dotnet"); Console.WriteLine(csDir); Directory.CreateDirectory(csDir); var cs = new DotNetClient(); cs.Write(ClassBuilder.AllClasses, Path.Combine(csDir, "RhinoCompute.cs"), filter); Console.ResetColor(); }
static void Main(string[] args) { const string rhinocommonPath = @"C:\dev\github\mcneel\rhino\src4\DotNetSDK\rhinocommon\dotnet"; Console.WriteLine("[BEGIN PARSE]"); Console.ForegroundColor = ConsoleColor.DarkGreen; ClassBuilder.BuildClassDictionary(rhinocommonPath); Console.ResetColor(); Console.WriteLine("[END PARSE]"); string[] filter = new string[] { ".AreaMassProperties", ".BezierCurve", ".Brep", ".BrepFace", ".Curve", ".Extrusion", ".Intersection", ".Mesh", ".NurbsCurve", ".NurbsSurface", ".SubD", ".Surface", ".VolumeMassProperties" }; var di = SharedRepoDirectory(); Console.ForegroundColor = ConsoleColor.Blue; var classes = ClassBuilder.FilteredList(ClassBuilder.AllClasses, filter); // Javascript Console.WriteLine("Writing javascript client"); var js = new JavascriptClient(); string javascriptPath = "compute.rhino3d.js"; if (di != null) { string dir = Path.Combine(di.FullName, "computeclient_js"); if (Directory.Exists(dir)) { javascriptPath = Path.Combine(dir, javascriptPath); } } js.Write(ClassBuilder.AllClasses, javascriptPath, filter); DirectoryInfo jsdocDirectory = new DirectoryInfo("docs\\javascript"); if (di != null) { string dir = Path.Combine(di.FullName, "computeclient_js", "docs"); if (Directory.Exists(dir)) { jsdocDirectory = new DirectoryInfo(dir); } } Console.WriteLine("Writing javascript docs"); RstClient.WriteJavascriptDocs(classes, jsdocDirectory); // Python Console.WriteLine("Writing python client"); string basePythonDirectory = ""; if (di != null) { string dir = Path.Combine(di.FullName, "computeclient_py"); if (Directory.Exists(dir)) { basePythonDirectory = dir; } } var py = new PythonClient(); py.Write(ClassBuilder.AllClasses, basePythonDirectory, filter); Console.WriteLine("Writing python docs"); RstClient.WritePythonDocs(basePythonDirectory, classes); // C# Console.WriteLine("Writing C# client"); var cs = new DotNetClient(); cs.Write(ClassBuilder.AllClasses, "RhinoCompute.cs", filter); Console.ResetColor(); }
public static void WriteJavascriptDocs(ClassBuilder[] classes, System.IO.DirectoryInfo di) { if (!di.Exists) { di.Create(); } foreach (var c in classes) { StringBuilder sb = new StringBuilder(); sb.AppendLine("RhinoCompute." + c.ClassName); sb.AppendLine("".PadLeft(("RhinoCompute." + c.ClassName).Length, '=')); sb.AppendLine(); sb.AppendLine($".. js:module:: RhinoCompute"); sb.AppendLine(); foreach (var(method, comments) in c.Methods) { string methodName = JavascriptClient.GetMethodName(method, c); if (string.IsNullOrWhiteSpace(methodName)) { continue; } sb.Append($".. js:function:: RhinoCompute.{c.ClassName}.{methodName}("); List <string> parameters = PythonClient.GetParameterNames(method, c, out int outParamCount); for (int i = 0; i < parameters.Count; i++) { sb.Append(parameters[i] + ", "); } sb.AppendLine("multiple=false)"); sb.AppendLine(); StringBuilder defSummary; List <ParameterInfo> parameterList; ReturnInfo returnInfo; PythonClient.DocCommentToPythonDoc(comments, method, 1, out defSummary, out parameterList, out returnInfo); if (defSummary.Length > 0) { var summaryLines = defSummary.ToString().Split(new char[] { '\n' }); foreach (var summaryLine in summaryLines) { if (!string.IsNullOrWhiteSpace(summaryLine)) { sb.AppendLine($" {summaryLine.Trim()}"); } } sb.AppendLine(); } foreach (var p in parameterList) { if (p.Description.Count == 0) { continue; } string type = PythonClient.ToPythonType(p.Type); if (type.IndexOf(' ') < 0) { sb.Append($" :param {type} {p.Name}: {p.Description[0]}"); } else { sb.Append($" :param {p.Name}: {p.Description[0]}"); } if (p.Description.Count > 1) { sb.AppendLine(" \\"); } else { sb.AppendLine(); } for (int i = 1; i < p.Description.Count; i++) { if (i == (p.Description.Count - 1)) { sb.AppendLine($" {p.Description[i]}"); } else { sb.AppendLine($" {p.Description[i]} \\"); } } if (type.IndexOf(' ') > 0) { sb.AppendLine($" :type {p.Name}: {type}"); } } sb.AppendLine(" :param bool multiple: (default False) If True, all parameters are expected as lists of equal length and input will be batch processed"); sb.AppendLine(); if (returnInfo.Description.Count > 0) { sb.Append($" :return: {returnInfo.Description[0]}"); if (returnInfo.Description.Count > 1) { sb.AppendLine(" \\"); } else { sb.AppendLine(); } for (int i = 1; i < returnInfo.Description.Count; i++) { if (i == (returnInfo.Description.Count - 1)) { sb.AppendLine($" {returnInfo.Description[i]}"); } else { sb.AppendLine($" {returnInfo.Description[i]} \\"); } } } sb.AppendLine($" :rtype: {PythonClient.ToPythonType(returnInfo.Type)}"); } var path = System.IO.Path.Combine(di.FullName, c.ClassName + ".rst"); System.IO.File.WriteAllText(path, sb.ToString()); } var indexPath = System.IO.Path.Combine(di.FullName, "index.rst"); WriteIndexFile(indexPath, "js", classes); }