static string Generate(SolutionDom sln)
		{
			XElement body;
			var doc = GetDoc(out body);
			
			body.Add(x("h1", sln.Name));

			XElement tbody;

			var table = Section(
				Names[Strings.Namespace + "_s"],
				x("table", a("class", "doc_table"), tbody = x("tbody"))
			);

			tbody.Add(BuildRow(new XElement[0], x("span", Names[Strings.Name]), Names[Strings.Description].ToSpan(), "th"));

			foreach (var ns in sln.Namespaces)
				tbody.Add(BuildRow(
					Enumerable.Empty<XElement>(),
					BuildNsUrl(ns.Name),
					XMLUtils.GetTagInnerXml(ns.DocInfo, "summary", Navigation, false)
					));

			body.Add(table);

			return doc.ToString();
		}
示例#2
0
		public static SolutionDom Build(string name, string[] assemblyFiles, string[] xmlDocFiles, string xmlNamespaceProjectFile = null, Func<MemberDom, bool> filterMembers = null, FindOptions findOptions = null)
		{
			if (findOptions == null)
				findOptions = new FindOptions(); //использовать значения по умолчанию

			IEnumerable<AssemblyDoc> docs = ParseDocfiles(xmlDocFiles);
			var asmsDict= AssemblyUtils.LoadAllAssemblies(assemblyFiles)
				.ToDictionary(_=>_.GetName().Name);
			var asmDoms = new List<AssemblyDom>();
			var errors = new List<WarningOrError>();
			foreach (var doc in docs)
			{
				AssemblyDom asmDom = null;
				try
				{
					asmDom = AssemblyDom.Build(doc, asmsDict[doc.Name], filterMembers, findOptions );
				}
				catch (Exception ex)
				{
					errors.Add(new WarningOrError{AssemblyName = doc.Name, InnerException = ex, ErrorType =WarningOrError.ErrorTypeEn.BindingWithReflection}); 
				}
				if (asmDom != null)
				{
					asmDoms.Add(asmDom);
					var error=GetUnboundError(asmDom);
					if(error!=null)
						errors.Add(error);
				}
			}
			var ret = new SolutionDom {Assemblies = asmDoms.ToArray(), Errors = errors, Name = name };
			ret.Namespaces = MergeNamespaces(ret.Assemblies.SelectMany(_ => _.Namespaces));
			ret.AllTypes = ret.Assemblies.SelectMany(_ => _.AllTypes).ToArray();
				//ret.Namespaces.SelectMany(_ => _.Types).ToArray();

			PopulateExtentionMethods.Populate(ret.AllTypes);
			MergeDocWithBaseClasses.Merge(ret.AllTypes);

			//namespaces
			if (xmlNamespaceProjectFile != null)
			{
				var comm = NamespaceCommentsParser.Parse(XDocument.Load(xmlNamespaceProjectFile).Root);

				foreach (var ns in ret.Namespaces)
				{
					NamespaceComments c;
					if (comm.TryGetValue(ns.Name, out c))
						ns.DocInfo = c.Comments;
				}
			}

			foreach (var type in ret.AllTypes)
				type.FillOverrideIndex();
			return ret;
		}
示例#3
0
		public static OfflineDynamicPage BuildSolution(SolutionDom solutionDom, bool onlyNamespaces = true)
		{
			var ret = new OfflineDynamicPage
			{
				RussianTitle = solutionDom.Name,
				RussianContent = GenerateHtml.Generate(solutionDom),
			};

			if (onlyNamespaces)
				AddNamespaces(ret, solutionDom.Namespaces);
			else
				foreach (var asm in solutionDom.Assemblies)
					AddAssembly(ret, asm);

			return ret;
		}
示例#4
0
        public static SolutionDom Build(string name, string[] assemblyFiles, string[] xmlDocFiles, string xmlNamespaceProjectFile = null, Func <MemberDom, bool> filterMembers = null, FindOptions findOptions = null)
        {
            if (findOptions == null)
            {
                findOptions = new FindOptions();                 //использовать значения по умолчанию
            }
            IEnumerable <AssemblyDoc> docs = ParseDocfiles(xmlDocFiles);
            var asmsDict = AssemblyUtils.LoadAllAssemblies(assemblyFiles)
                           .ToDictionary(_ => _.GetName().Name);
            var asmDoms = new List <AssemblyDom>();
            var errors  = new List <WarningOrError>();

            foreach (var doc in docs)
            {
                AssemblyDom asmDom = null;
                try
                {
                    asmDom = AssemblyDom.Build(doc, asmsDict[doc.Name], filterMembers, findOptions);
                }
                catch (Exception ex)
                {
                    errors.Add(new WarningOrError {
                        AssemblyName = doc.Name, InnerException = ex, ErrorType = WarningOrError.ErrorTypeEn.BindingWithReflection
                    });
                }
                if (asmDom != null)
                {
                    asmDoms.Add(asmDom);
                    var error = GetUnboundError(asmDom);
                    if (error != null)
                    {
                        errors.Add(error);
                    }
                }
            }
            var ret = new SolutionDom {
                Assemblies = asmDoms.ToArray(), Errors = errors, Name = name
            };

            ret.Namespaces = MergeNamespaces(ret.Assemblies.SelectMany(_ => _.Namespaces));
            ret.AllTypes   = ret.Assemblies.SelectMany(_ => _.AllTypes).ToArray();
            //ret.Namespaces.SelectMany(_ => _.Types).ToArray();

            PopulateExtentionMethods.Populate(ret.AllTypes);
            MergeDocWithBaseClasses.Merge(ret.AllTypes);

            //namespaces
            if (xmlNamespaceProjectFile != null)
            {
                var comm = NamespaceCommentsParser.Parse(XDocument.Load(xmlNamespaceProjectFile).Root);

                foreach (var ns in ret.Namespaces)
                {
                    NamespaceComments c;
                    if (comm.TryGetValue(ns.Name, out c))
                    {
                        ns.DocInfo = c.Comments;
                    }
                }
            }

            foreach (var type in ret.AllTypes)
            {
                type.FillOverrideIndex();
            }
            return(ret);
        }