public static JSDScope GenerateFrom(JToken obj, JSONParseOptions opts = null) { JSDScope scope = new JSDScope(); JSONParseOptions optsval = opts ?? new JSONParseOptions(); JSDType rootType = scope.ObjSpec(obj, null, optsval); TypeDef rootTypeDef = scope.TypeDefinitions.First(x => x.JSDType.Equals(rootType)); scope.TypeDefinitions.Remove(rootTypeDef); scope.TypeDefinitions.Add(rootTypeDef); scope.TypeDefinitions.Reverse();// move root typedef to the front of list return(scope); }
public static JSDScope Parse(string input) { input = input.Replace("\r\n", "\n"); //Convert to UNIX string Regex rx = new Regex(@"\/\*\*(?:([^@\n]*(?:\s*\*\s*(?!\s*@[a-zA-Z]+)[^\r\n]*)*)\s*\*\s*|\s+)@typedef\s+{([^}]+)}\s+(\w+)(.*?)\*\/", RegexOptions.Singleline | RegexOptions.Compiled); JSDScope result = new JSDScope(); MatchCollection matches = rx.Matches(input); foreach (Match match in matches) { string description = match.Captures[0].Value; description = description.Trim(); description = new Regex(@"^\s*\*[ \t\f]*").Replace(description, ""); description.Replace(" * ", ""); description.Replace("*", ""); //result.TypeDefinitions.Add() } return(null); }