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

Getting ReturnType from ApiDocMember without Html already embedded #708

Closed
TheAngryByrd opened this issue Sep 25, 2021 · 6 comments
Closed

Comments

@TheAngryByrd
Copy link

Is there a way to get the ReturnType name for a ApiDocMember signature without it already being wrapped in html?

Actual

// Some library
let add a b = a + b

// do work to get ApiDocComment

let returnType = adm.ReturnInfo.ReturnType.Value  // <code>int</code>

Desired

let returnType = adm.ReturnInfo.ReturnType.Value  // int
@MangelMaxime
Copy link

I was coming to ask the same question.

I tried to look at the information available via the debugger and I don't think there is one yet.

The HTML have some benefit of having the link generated to the referenced type:

<code><span><a href="/reference/nacara-core-types-pagecontext.html">PageContext</a>&#32;array</span></code>

However, in my case the generated HTML doesn't look like I want it to be. So I need to parse it to extract the information from it.

It would be nice to have the needed information to generate the HTML by ourself.

@MangelMaxime
Copy link

This is kind of possible to have access to the returnType information but this is not trivial.

Given en entity:

// Cast it to this sub-type
let entity = entity.Symbol :?> FSharpMemberOrFunctionOrValue
// All the type information are available in
entity.FullType

// But this also includes the parameters for the function, so this means we need to skip the parameters to only extract the returnType information.

// The number of parameters can be found from
let (ApiDocMemberDetails(usageHtml, paramTypes, returnType, modifiers, typars, baseType, location, compiledName)) =
    entity.Details
    
let parameterCount = paramTypes.Length

@dsyme
Copy link
Contributor

dsyme commented Nov 10, 2021

@TheAngryByrd @MangelMaxime Are you after a textual representation of the type or the FSharpType?

On the whole the ApiDocsModel doesn't make FSharpType available except via the symbol but there's no real harm in doing it

@dsyme
Copy link
Contributor

dsyme commented Nov 10, 2021

@MangelMaxime I added the FCS object for a bunch of the items here: #727

@MangelMaxime
Copy link

Hello @dsyme,

With the current situation of Nacara, I am after the instance of FSharpType or something equivalent which contains the type information resolved by FCS.

This is needed in order to:

  1. Generates the textual representation in a way that allows customisation of the colors and styling.
  2. Generates the links information only for the API that I know is documented. Avoid dead links or links that redirect to F# documentation when the types is not coming from FSharp.Core

Right now in Nacara, all the code shown at the top of the pages are generated from the FCS types like FSharpType, FSharpGenericParameter.

The only exception is the ReturnInfo which use the HTML provided by F# formatting as at first I didn't find a way to access it. It seems like I found a workaround in the past according to my previous comments. But this is not as easy as doing XXX.ReturnInfo.Type

@dsyme
Copy link
Contributor

dsyme commented Nov 10, 2021

Yup, this is done in #727, release should be coming through the pipe.

@dsyme dsyme closed this as completed Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants