Exemplo n.º 1
0
        /// <summary>
        /// Returns the parameters from the command line arguments
        /// or from the console by prompting the user.
        /// </summary>
        /// <param name="args">Command-line arguments.</param>
        /// <param name="changset">Changset number.</param>
        /// <param name="templateFile">Path to template file.</param>
        /// <param name="comlibPath">ComLib version.</param>
        /// <param name="wikiOutput">Output file for wiki text.</param>
        private static DocSettings GetParameters(string[] args)
        {
            var settings = new DocSettings();

            // Do we have exactly 3 arguments?
            if (args.GetLength(0) == 5)
            {
                // Yes, get the parameters from the command line arguments.
                settings.ChangeSet = args[0];
                settings.Template  = args[1];
                settings.ComLib    = args[2];
                settings.DocFile   = args[3];
                settings.XML       = args[4];
            }
            else
            {
                // No, prompt the user.
                settings.ChangeSet = GetParameter(prompts[0], string.Empty);
                settings.Template  = GetParameter(prompts[1], defaultTemplate);
                settings.ComLib    = GetParameter(prompts[2], defaultComLib);
                settings.DocFile   = GetParameter(prompts[3], defaultWiki);
                settings.XML       = GetParameter(prompts[4], defaultXmlDoc);
            }

            // Make sure the comlib path does not end with a \ char.
            if (settings.ComLib.EndsWith("\\"))
            {
                settings.ComLib = settings.ComLib.Substring(0, settings.ComLib.Length - 1);
            }

            return(settings);
        }
        public EmbeddedSpecData_smoke_tester()
        {
            var settings = new DocSettings
            {
                Root = TestingContext.FindProjectFolder()
            };

            theEmbeddedData = new EmbeddedSpecData(settings);
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            var settings = new DocSettings
            {
                Root = ".".ToFullPath()
            };

            theEmbeddedData = new EmbeddedSpecData(settings);
        }
        public EmbeddedSpecData_smoke_tester()
        {
            var settings = new DocSettings
            {
                Root = TestingContext.FindProjectFolder()
            };

            theEmbeddedData = new EmbeddedSpecData(settings);
        }
Exemplo n.º 5
0
        public TopicMiddleware(Func<IDictionary<string, object>, Task> inner, DocProject project, IHtmlGenerator generator, DocSettings settings)
        {
            _inner = inner;
            _project = project;
            _generator = generator;
            _settings = settings;

            var stream = Assembly.GetExecutingAssembly()
                .GetManifestResourceStream(typeof(TopicMiddleware), "WebsocketsRefresh.txt");

            _webSocketScript = stream.ReadAllText();
            _topicJS = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Program),"topics.js").ReadAllText();
        }
Exemplo n.º 6
0
        public TopicMiddleware(DocProject project, IHtmlGenerator generator, DocSettings settings)
        {
            _project   = project;
            _generator = generator;
            _settings  = settings;

            var topicAssembly = typeof(TopicMiddleware).GetAssembly();

            var stream = topicAssembly.GetManifestResourceStream("StorytellerDocGen.Runner.WebsocketsRefresh.txt");

            _webSocketScript = stream.ReadAllText();
            _topicJS         = topicAssembly.GetManifestResourceStream("StorytellerDocGen.topics.js").ReadAllText();
        }
Exemplo n.º 7
0
        public TopicMiddleware(Func <IDictionary <string, object>, Task> inner, DocProject project, IHtmlGenerator generator, DocSettings settings)
        {
            _inner     = inner;
            _project   = project;
            _generator = generator;
            _settings  = settings;

            var stream = Assembly.GetExecutingAssembly()
                         .GetManifestResourceStream(typeof(TopicMiddleware), "WebsocketsRefresh.txt");

            _webSocketScript = stream.ReadAllText();
            _topicJS         = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Program), "topics.js").ReadAllText();
        }
Exemplo n.º 8
0
        public TopicMiddleware(DocProject project, IHtmlGenerator generator, DocSettings settings)
        {
            _project = project;
            _generator = generator;
            _settings = settings;

            var topicAssembly = typeof(TopicMiddleware).GetAssembly();

            var stream = topicAssembly.GetManifestResourceStream("dotnet-stdocs.Runner.WebsocketsRefresh.txt");

            _webSocketScript = stream.ReadAllText();
            _topicJS = topicAssembly.GetManifestResourceStream("dotnet-stdocs.topics.js").ReadAllText();
        }
Exemplo n.º 9
0
        public CommandUsageCache(DocSettings settings)
        {
            _settings = settings;

            _reports = new Cache<string, CommandLineApplicationReport>(app =>
            {
                var file = _settings.Root.AppendPath("content", app + ".usage.xml");
                if (!File.Exists(file))
                {
                    throw new FileNotFoundException("Cannot find a command usage file for {0} at {1}".ToFormat(app, file));
                }

                var serializer = new XmlSerializer(typeof (CommandLineApplicationReport));
                using (var reader = new StreamReader(file))
                {
                    return serializer.Deserialize(reader).As<CommandLineApplicationReport>();
                }
            });
        }
Exemplo n.º 10
0
        public CommandUsageCache(DocSettings settings)
        {
            _settings = settings;

            _reports = new Cache <string, CommandLineApplicationReport>(app =>
            {
                var file = _settings.Root.AppendPath("content", app + ".usage.xml");
                if (!File.Exists(file))
                {
                    throw new FileNotFoundException("Cannot find a command usage file for {0} at {1}".ToFormat(app, file));
                }

                var serializer = new XmlSerializer(typeof(CommandLineApplicationReport));
                using (var reader = new StreamReader(file))
                {
                    return(serializer.Deserialize(reader).As <CommandLineApplicationReport>());
                }
            });
        }
 public override void SetUp()
 {
     _settings = Context.Service <DocSettings>();
 }
Exemplo n.º 12
0
        public EmbeddedSpecData(DocSettings settings)
        {
            _settings = settings;

            _specs = new Lazy<IDictionary<string, EmbeddedSpec>>(readSpecs);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            try
            {
                // Get the parameters.
                var settings = DocSettings.LoadFromConfig();
                if (ConfigurationManager.AppSettings["useCmdline"] == "true")
                {
                    settings = GetParameters(args);
                }

                // Read the xml.
                SortedList <int, Component> lst = ReadXML(settings.ComLib, settings.XML);

                // Read the template file.
                Console.WriteLine("Reading the template file...");
                string templateContents = GetFileContents(settings.Template);

                // Get the comlib version and the names of the example files.
                Console.WriteLine("Extracting the assembly version...");
                string comlibversion = GetComLibVersion(settings.ComLib + pathToAssembly);

                // Create the content for each one of the examples.
                Console.WriteLine("Reading the example source code files...");
                StringBuilder sb = new StringBuilder();
                foreach (int key in lst.Keys)
                {
                    Component comp    = lst[key];
                    int       compNum = key + 1;
                    if (comp.WikiEnabled)
                    {
                        string exampleFile = settings.ComLib + settings.Examples + "\\" + comp.ExampleFile;
                        if (WikiStyle.Xml_Markers == comp.Style)
                        {
                            sb.Append(Substitute(exampleFile, comp.GetDescription(), GetFileContents(exampleFile),
                                                 templateContents, comlibversion,
                                                 comp.Name, comp.FileReference,
                                                 settings.ChangeSet, comp.FileId, false, compNum));
                        }
                        else if (WikiStyle.Full_File == comp.Style)
                        {
                            sb.Append(Substitute(exampleFile, comp.GetDescription(), GetFileContents(exampleFile),
                                                 templateContents, comlibversion,
                                                 comp.Name, comp.FileReference,
                                                 settings.ChangeSet, comp.FileId, true, compNum));
                        }
                        else
                        {
                            sb.Append(Substitute(exampleFile, comp.GetDescription(), "Example not available",
                                                 templateContents, comlibversion,
                                                 comp.Name, comp.FileReference,
                                                 settings.ChangeSet, comp.FileId, false, compNum));
                        }
                    }
                }

                // Write it out to the output file.
                Console.WriteLine("Writing the wiki output file...");
                using (StreamWriter sw = new StreamWriter(settings.DocFile, false, System.Text.Encoding.Default))
                {
                    sw.Write(sb.ToString());
                }

                Console.Write("Done.");
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("An error has occurred, please see the program output and the stack trace " +
                                  "to determine the cause of the error.");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 14
0
 public Exporter(DocSettings settings, IHtmlGenerator generator)
 {
     _settings = settings;
     _generator = generator;
 }
 public FilePathTransformHandler(DocSettings settings)
 {
     _settings = settings;
 }
 public Exporter(DocSettings settings, IHtmlGenerator generator)
 {
     _settings  = settings;
     _generator = generator;
 }
Exemplo n.º 17
0
        public EmbeddedSpecData(DocSettings settings)
        {
            _settings = settings;

            _specs = new Lazy <IDictionary <string, EmbeddedSpec> >(readSpecs);
        }
Exemplo n.º 18
0
 public HtmlGenerator(DocSettings settings, ITransformer transformer)
 {
     _transformer = transformer;
     _settings = settings;
 }
Exemplo n.º 19
0
 public ProjectWebsiteExportUrlResolver(DocSettings settings)
 {
     _projectName = settings.ProjectName;
 }
Exemplo n.º 20
0
 public HtmlGenerator(DocSettings settings, ITransformer transformer)
 {
     _transformer = transformer;
     _settings    = settings;
 }
 public VersionTransformHandler(DocSettings settings)
 {
     _settings = settings;
 }
 public FilePathTransformHandler(DocSettings settings)
 {
     _settings = settings;
 }
Exemplo n.º 23
0
 public SampleExplorer(ISampleCache cache, DocSettings settings)
 {
     _cache    = cache;
     _settings = settings;
 }
Exemplo n.º 24
0
 public SpecificationContext()
 {
     _services    = new InMemoryServiceLocator();
     _docSettings = DocSettings.ForTesting();
     _services.Add(_docSettings);
 }
 public VersionTransformHandler(DocSettings settings)
 {
     _settings = settings;
 }
 public ProjectWebsiteExportUrlResolver(DocSettings settings)
 {
     _projectName = settings.ProjectName;
 }
Exemplo n.º 27
0
 public SampleExplorer(ISampleCache cache, DocSettings settings)
 {
     _cache = cache;
     _settings = settings;
 }