private MdTable GetDetailsTable() { // TODO: Type var table = new MdTable(new MdTableRow("", "")); if (!String.IsNullOrWhiteSpace(m_Model.InformationalName)) { table.Add(new MdTableRow("Informational Name:", m_Model.InformationalName)); } table.Add(new MdTableRow("Position:", m_Model.Position.ToString())); table.Add(new MdTableRow("Required:", m_Model.Required ? "Yes" : "No")); if (!String.IsNullOrWhiteSpace(m_Model.ValuePlaceHolderName)) { table.Add(new MdTableRow("Value:", m_Model.ValuePlaceHolderName)); } if (m_Model.AcceptedValues != null) { table.Add(new MdTableRow("Accepted values:", m_Model.AcceptedValues.Select(x => new MdCodeSpan(x)).Join(", "))); } if (m_Model.DefaultValue != null) { table.Add(new MdTableRow("Default value:", m_Model.DefaultValue)); } else { table.Add(new MdTableRow("Default value:", new MdEmphasisSpan("None"))); } return(table); }
private MdTable GetDetailsTable() { // TODO: Type var table = new MdTable(new MdTableRow("", "")); if (m_Model.HasName) { table.Add(new MdTableRow("Name:", m_Model.Name)); } if (m_Model.HasShortName) { if (!m_Model.HasName) { table.Add(new MdTableRow("Name:", m_Model.ShortName)); } else { table.Add(new MdTableRow("Short name:", m_Model.ShortName)); } } table.Add(new MdTableRow("Position:", new MdEmphasisSpan("None (Switch Parameter)"))); table.Add(new MdTableRow("Required:", new MdEmphasisSpan("No (Switch Parameter)"))); table.Add(new MdTableRow("Default value:", new MdCodeSpan("false"))); return(table); }
private MdTable GetCommandsTable() { var table = new MdTable(new MdTableRow("Name", "Description")); foreach (var command in m_Model.Commands) { var commandPage = m_DocumentSet[m_PathProvider.GetPath(command)]; var link = m_DocumentSet.GetLink(this, commandPage, command.Name); table.Add(new MdTableRow(link, command.Description ?? "")); } return(table); }
private void AddSimpleMembersSection(MdContainerBlock block, string sectionHeading, IEnumerable <SimpleMemberDocumentation> members) { if (members.Any()) { block.Add(new MdHeading(sectionHeading, 2)); var table = new MdTable(new MdTableRow("Name", "Description")); foreach (var member in members.OrderBy(x => x.Name, StringComparer.Ordinal)) { table.Add( new MdTableRow( CreateLink(member.MemberId, member.Name), ConvertToSpan(member.Summary) )); } block.Add(table); } }
protected void AddOverloadsTableSection(MdContainerBlock block, IEnumerable <TOverload> overloads, int headingLevel) { var table = new MdTable(new MdTableRow("Signature", "Description")); foreach (var overload in overloads) { // optimization: we know the section we're linking to is on the same page // so we can create the link to the anchor without going through PageBase.CreateLink() var link = new MdLinkSpan(overload.Signature, "#" + m_Headings.Value[overload.MemberId].Anchor); table.Add( new MdTableRow(link, ConvertToSpan(overload.Summary)) ); } block.Add( new MdHeading("Overloads", headingLevel), table ); }
private void AddNestedTypesSection(MdContainerBlock block) { if (Model.NestedTypes.Count == 0) { return; } block.Add(new MdHeading(2, "Nested Types")); var table = new MdTable(new MdTableRow("Name", "Description")); foreach (var type in Model.NestedTypes.OrderBy(x => x.DisplayName, StringComparer.Ordinal)) { table.Add( new MdTableRow( CreateLink(type.MemberId, type.DisplayName), ConvertToSpan(type.Summary) )); } block.Add(table); }
private void AddOverloadableMembersSection(MdContainerBlock block, string sectionHeading, IEnumerable <OverloadDocumentation> overloads) { if (overloads.Any()) { var table = new MdTable(new MdTableRow("Name", "Description")); foreach (var ctor in overloads.OrderBy(x => x.Signature, StringComparer.Ordinal)) { table.Add( new MdTableRow( CreateLink(ctor.MemberId, ctor.Signature), ConvertToSpan(ctor.Summary) )); } block.Add( new MdHeading(sectionHeading, 2), table ); } }
private void AddTypeTable(MdContainerBlock block, string heading, IEnumerable <TypeDocumentation> types) { if (!types.Any()) { return; } block.Add(new MdHeading(2, heading)); var table = new MdTable(new MdTableRow("Name", "Description")); foreach (var type in types.OrderBy(x => x.DisplayName, StringComparer.Ordinal)) { table.Add( new MdTableRow( CreateLink(type.MemberId, type.DisplayName), ConvertToSpan(type.Summary) )); } block.Add(table); }
protected override MdBlock ConvertToBlock() { MdSpan GetLinkOrEmptySpan(string?text, string uri, bool italic = false) { return((text == null || String.IsNullOrEmpty(text)) ? (MdSpan)MdEmptySpan.Instance : new MdLinkSpan(italic ? new MdEmphasisSpan(text) : (MdSpan)text, uri)); } // only include the "Name" column, if any option has a 'long' name var addNameColumn = m_Model.NamedParameters.Any(x => x.HasName) || m_Model.SwitchParameters.Any(x => x.HasName); // only include the "Short Name" column if option has a short name var addShortNameColumn = m_Model.NamedParameters.Any(x => x.HasShortName) || m_Model.SwitchParameters.Any(x => x.HasShortName); // only include the position column if the command has any unnamed parameters var addPositionColumn = m_Model.PositionalParameters.Any(); // only add "Required" column if at least on option or value is mandatory var addRequiredColumn = m_Model.NamedParameters.Any(x => x.Required) || m_Model.PositionalParameters.Any(x => x.Required); // create empty table with header row var headerRow = new MdTableRow(); headerRow.AddIf(addPositionColumn, "Position"); headerRow.AddIf(addNameColumn, "Name"); headerRow.AddIf(addShortNameColumn && !addNameColumn, "Name"); headerRow.AddIf(addShortNameColumn && addNameColumn, "Short Name"); headerRow.AddIf(addRequiredColumn, "Required"); headerRow.Add("Description"); var table = new MdTable(headerRow); // add a row for every positional parameter foreach (var positionalParameter in m_Model.PositionalParameters.OrderBy(x => x.Position)) { var link = "#" + m_GetPositionalParameterAnchor(positionalParameter); var row = new MdTableRow(); // add index and link to details anchor row.Add(GetLinkOrEmptySpan(positionalParameter.Position.ToString(), link)); // add name (if a name of the value was specified) and link to details anchor row.AddIf(addNameColumn, GetLinkOrEmptySpan(positionalParameter.InformationalName, link, italic: true)); // if "Name" column was skipped, add the name in the "Short Name" column and link to details anchor, // if the name was already added to the name column, add an empty cell row.AddIf(addShortNameColumn && !addNameColumn, GetLinkOrEmptySpan(positionalParameter.InformationalName, link, italic: true)); row.AddIf(addShortNameColumn && addNameColumn, MdEmptySpan.Instance); // add value for "Required" column row.AddIf(addRequiredColumn, positionalParameter.Required ? "Yes" : "No"); // add help text to "Description" column row.Add(positionalParameter.Description ?? ""); table.Add(row); } // Add a row for every named parameter foreach (var namedParameter in m_Model.NamedParameters) { var link = "#" + m_GetNamedParameterAnchor(namedParameter); var row = new MdTableRow(); // add empty cell for position because option has no position row.AddIf(addPositionColumn, MdEmptySpan.Instance); // if specified, add name and link to details anchor row.AddIf(addNameColumn, GetLinkOrEmptySpan(namedParameter.Name, link)); // if specified, add shot name and link to details anchor row.AddIf(addShortNameColumn, GetLinkOrEmptySpan(namedParameter.ShortName?.ToString(), link)); // add value for "Required" column row.AddIf(addRequiredColumn, namedParameter.Required ? "Yes" : "No"); // add help text to "Description" column row.Add(namedParameter.Description ?? ""); table.Add(row); } // Add a row for every switch parameter foreach (var switchParameter in m_Model.SwitchParameters) { var link = "#" + m_GetSwitchParameterAnchor(switchParameter); var row = new MdTableRow(); // add empty cell for position because option has no position row.AddIf(addPositionColumn, MdEmptySpan.Instance); // if specified, add name and link to details anchor row.AddIf(addNameColumn, GetLinkOrEmptySpan(switchParameter.Name, link)); // if specified, add shot name and link to details anchor row.AddIf(addShortNameColumn, GetLinkOrEmptySpan(switchParameter.ShortName?.ToString(), link)); // add value for "Required" column (switch parameters are never required) row.AddIf(addRequiredColumn, "No"); // add help text to "Description" column row.Add(switchParameter.Description ?? ""); table.Add(row); } return(table); }