Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle href elements on a, see, and xref xml doc comments #839

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 31 additions & 59 deletions src/FsAutoComplete.Core/TipFormatter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -204,26 +204,24 @@ module private Format =
|> Some
}
|> applyFormatter

let private link text uri = $"[`%s{text}`](%s{uri})"
let private code text = $"`%s{text}`"

let private anchor =
{
TagName = "a"
Formatter =
function
| VoidElement _ ->
None
| VoidElement attributes ->
match href attributes with
| Some href -> Some (link href href)
| None -> None

| NonVoidElement (innerText, attributes) ->
let href =
match href attributes with
| Some href ->
href

| None ->
""

sprintf "[%s](%s)" innerText href
|> Some
match href attributes with
| Some href -> Some (link innerText href)
| None -> Some (code innerText)
}
|> applyFormatter

Expand Down Expand Up @@ -263,7 +261,7 @@ module private Format =
| Some cref -> Some $"``{extractMemberText cref}``"
| None ->
match langword attrs with
| Some langword -> Some $"`%s{langword}`"
| Some langword -> Some (code langword)
| None -> None
{
TagName = "see"
Expand All @@ -272,7 +270,10 @@ module private Format =
| VoidElement attributes -> formatFromAttributes attributes
| NonVoidElement (innerText, attributes) ->
if String.IsNullOrWhiteSpace innerText then formatFromAttributes attributes
else Some $"`{innerText}`"
else
match href attributes with
| Some externalUrl -> Some (link innerText externalUrl)
| None -> Some $"`{innerText}`"
}
|> applyFormatter

Expand All @@ -283,27 +284,16 @@ module private Format =
function
| VoidElement attributes ->
match href attributes with
| Some href ->
// TODO: Add config to generates command
"`" + extractMemberText href + "`"
|> Some

| Some href -> Some (link href href)
| None ->
None

| NonVoidElement (innerText, attributes) ->
if String.IsNullOrWhiteSpace innerText then
match href attributes with
| Some href ->
// TODO: Add config to generates command
"`" + extractMemberText href + "`"
|> Some

| None ->
None
else
"`" + innerText + "`"
|> Some
| Some href -> Some (link innerText href)
| None -> None
else Some (code innerText)
}
|> applyFormatter

Expand All @@ -314,26 +304,17 @@ module private Format =
function
| VoidElement attributes ->
match name attributes with
| Some name ->
"`" + name + "`"
|> Some

| None ->
None
| Some name -> Some (code name)
| None -> None

| NonVoidElement (innerText, attributes) ->
if String.IsNullOrWhiteSpace innerText then
match name attributes with
| Some name ->
// TODO: Add config to generates command
"`" + name + "`"
|> Some

| None ->
None
else
"`" + innerText + "`"
|> Some
Some (code name)
| None -> None
else Some (code innerText)

}
|> applyFormatter
Expand All @@ -345,26 +326,17 @@ module private Format =
function
| VoidElement attributes ->
match name attributes with
| Some name ->
"`" + name + "`"
|> Some

| None ->
None
| Some name -> Some (code name)
| None -> None

| NonVoidElement (innerText, attributes) ->
if String.IsNullOrWhiteSpace innerText then
match name attributes with
| Some name ->
// TODO: Add config to generates command
"`" + name + "`"
|> Some

| None ->
None
else
"`" + innerText + "`"
|> Some
Some (code name)
| None -> None
else Some (code innerText)
}
|> applyFormatter

Expand Down Expand Up @@ -846,7 +818,7 @@ type private XmlDocMember(doc: XmlDocument, indentationSize : int, columnOffset
member __.ToFullEnhancedString() =
let content =
summary
+ Section.fromList "" remarks
+ Section.fromList "Remarks" remarks
+ Section.fromKeyValueList "Type parameters" typeParams
+ Section.fromKeyValueList "Parameters" parameters
+ Section.fromOption "Returns" returns
Expand All @@ -865,7 +837,7 @@ type private XmlDocMember(doc: XmlDocument, indentationSize : int, columnOffset
member __.ToDocumentationString() =
"**Description**" + nl + nl
+ summary
+ Section.fromList "" remarks
+ Section.fromList "Remarks" remarks
+ Section.fromKeyValueList "Type parameters" typeParams
+ Section.fromKeyValueList "Parameters" parameters
+ Section.fromOption "Returns" returns
Expand Down