public void RelativeNameWithBackwardsSlashes()
        {
            string filename = @"C:\game\source\file.lua";
            string baseDirectory = @"C:\game\";

            SourceCode source = new SourceCode(filename, baseDirectory, "");
            Assert.AreEqual("source/file.lua", source.RelativeName);
        }
        public void RelativeName()
        {
            string filename = "C:/game/source/file.lua";
            string baseDirectory = "C:/game/";

            SourceCode source = new SourceCode(filename, baseDirectory, "");
            Assert.AreEqual("source/file.lua", source.RelativeName);
        }
        public void SetUp()
        {
            string contents =
                   "function table.copy(t)\n" +
                   "    local copy = {}\n" +
                   "    for key, value in pairs(t) do\n" +
                   "        copy[key] = value\n" +
                   "    end\n" +
                   "    return copy\n" +
                   "end";

            source = new SourceCode(contents);
        }
        public void SetUp()
        {
            baseDirectory = "C:/lua/Weapons/";
            filename = "C:/lua/Weapons/Shotgun.lua";

            string[] contentsArray = new string[] {
                                         "class 'Shotgun' (Weapon)",
                                         ""                        ,
                                         "function Shotgun:Fire()" ,
                                         "    // Fire weapon"      ,
                                         "end"
                                     };

            contents = String.Join("\n", contentsArray);

            sourceCode = new SourceCode(filename, baseDirectory, contents);
        }
Exemple #5
0
 public Declaration(SourceCode source, int line, int coloumn)
 {
     SourceCode = source;
     Line = line;
     Column = coloumn;
 }
Exemple #6
0
        public override void RunFromArgs(string[] args)
        {
            string generatorName = null;
            string outName = null;
            OptionSet optionSet = new OptionSet()
            {
                {"g|generator=", x => generatorName = x},
                {"o|out=", x => outName = x}
            };

            List<string> codeDirs = optionSet.Parse(args);

            if (String.IsNullOrWhiteSpace(generatorName))
            {
                generatorName = "Static";
            }

            if (codeDirs.Count == 0)
            {
                codeDirs.Add("%game%");
            }

            IOutputGenerator generator = CreateGenerator(generatorName);
            generator.Out = outName;

            SparkParser parser = new SparkParser();
            Game game = new Game();

            foreach (string unformattedCodeDir in codeDirs)
            {
                string codeDir = FormatFolderPath(unformattedCodeDir);

                string[] ignoreList;
                try
                {
                    ignoreList = File.ReadAllLines(Utils.PathInExecutingDir("ns2docs-ignore.txt"));
                }
                catch (FileNotFoundException)
                {
                    ignoreList = new string[0];
                }

                IEnumerable<string> files = FindFiles(codeDir, ignoreList);
                foreach (string file in files)
                {
                    string contents = ReadAllText(file);
                    contents = contents.Replace("Copyright \uFFFD", "Copyright ©");

                    SourceCode sourceCode = new SourceCode(file, codeDir, contents);
                    sourceCode.LastWriteTime = new FileInfo(file).LastWriteTime;
                    sourceCode.PredictLibrary();

                    try
                    {
                        parser.ParseSourceCode(game, sourceCode);
                        Console.WriteLine(String.Format(Resources.ParsedLuaFile, sourceCode.RelativeName));
                    }
                    catch (ParseException e)
                    {
                        var msg = String.Format(Resources.ParseError, file, e.InnerException.Message);
                        Console.WriteLine(msg);

                        if (Debugger.IsAttached)
                        {
                            throw e;
                        }
                    }

                }
            }
            game.ReapPotentialStaticFields();

            GenerateDocumentation(generator, game);
        }