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

Use doccoms from signature and implementation files for quickinfo tooltips #2662

Closed
wants to merge 6 commits into from

Conversation

cloudRoutine
Copy link
Contributor

The current way that documentation comments behave with quickinfo tooltips is rather odd and has been a pet peeve of mine for a long time.


When you add doccoms in the signature they don't show up in the corresponding implementation

If you open a different implementation file it uses the doccoms from the sig and overwrites any doccoms you may have added in the implementation file

Now it shows doccoms from the sig in its corresponding implementation file, and if you add additional doccoms in the implementation the tooltip will show both of them.


The doccoms from the implementation files are on the bottom because these are merely supplementary and will not be included in the xml documentation created for the project.

@vasily-kirichenko
Copy link
Contributor

Awesome. What about showing a warning of some sort if documentation in sig and implementation files differ (and a quick fix to synchronize them in either way ;) ?

@cloudRoutine
Copy link
Contributor Author

The doccoms in the implementation files are more like "design time" notes, things you want to show up in other implementer's tooltips but prefer not to expose publicly like the doccoms in the signature file.

I don't think synchronization adds anything useful as the doccoms from the signature will always show in the tooltips. If anything you'd want to delete the doccoms in the implementation file. Making them the same would just duplicate the content.


type Async with
/// Better implementation of Async.AwaitTask that correctly passes the exception of a failed task to the async mechanism
static member AwaitTaskCorrect (task:Task) : unit Async =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async<unit> please.

|> ignore)

/// Better implementation of Async.AwaitTask that correctly passes the exception of a failed task to the async mechanism
static member AwaitTaskCorrect (task:'T Task) : 'T Async =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task<'T> and Async<'T> please

type Async with
/// Better implementation of Async.AwaitTask that correctly passes the exception of a failed task to the async mechanism
static member AwaitTaskCorrect (task:Task) : unit Async =
Async.FromContinuations (fun (successCont,exceptionCont,_cancelCont) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this AwaitTask is better, then we should start an RFC to provide a version of it in FSharp.Core please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eiriktsarpalis wrote it

let tooltipInfoPair = asyncMaybe {
match findSigDeclarationResult with
| FSharpFindDeclResult.DeclNotFound _failReason ->
return (None , Some backupTooltipInfo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No space before comma please

let! findImplDefinitionResult =
checkFileResults.GetDeclarationLocationAlternate
( idRange.StartLine, idRange.EndColumn, lineText
, lexerSymbol.FullIsland, preferFlag=false) |> liftAsync
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put comma at end-of-line please, not start of line


/// Load times used to reset type checking properly on script/project load/unload. It just has to be unique for each project load/reload.
/// Not yet sure if this works for scripts.
let fakeDateTimeRepresentingTimeLoaded x = DateTime(abs (int64 (match x with null -> 0 | _ -> x.GetHashCode())) % 103231L)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this added in this PR? It doesn't seem to be mentioned elsewhere in the PR?

@dsyme
Copy link
Contributor

dsyme commented Mar 20, 2017

@cloudRoutine An alternative is to fix this within the compiler itself, so that the specification of documentation generation for the language itself changes to combine documentation from signature and implementation. That is preferable in many ways because it solves the problem consistently across all F# tooling including Ionide and Fable.

If implementation documentation is empty then it is uncontroversial to use signature documentation.

However frequently documentation is duplicated in signature and implementation, which raises questions about what to do in that case.

@KevinRansom
Copy link
Member

build error:

"D:\j\workspace\release_ci_pa---3f142ccc\build-everything.proj" (default target) (1) ->
"D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\fsharp-vsintegration-unittests-build.proj" (Build target) (38) ->
"D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\VisualFSharp.Unittests.fsproj" (Build target) (40) ->
(CoreCompile target) -> 
  D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\QuickInfoProviderTests.fs(102,37): error FS0039: The field, constructor or member 'ProvideQuickInfo' is not defined. [D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\VisualFSharp.Unittests.fsproj]

    13 Warning(s)
    1 Error(s)

@cloudRoutine
Copy link
Contributor Author

@KevinRansom an issue I've run into with testing new features built around the Roslyn functionality is that there's no easy way to create a workspace to test it out with. Since the default workspace implementations reject all code that isn't C# or vb funtions/methods that rely on Document or Project connections inside of a solution are really hard to test.

@cloudRoutine
Copy link
Contributor Author

@dsyme maybe that can come later, but I'm trying to address a more immediate concern I've had while working on this repo in particular due to the extensive use of .fsi files.

However frequently documentation is duplicated in signature and implementation, which raises questions about what to do in that case.

this is a crude workaround due to inadequate tooling support and I think trying to account for it is going to end up in a lot of generated documentation suddenly becoming very messy. Trying to establish a good heuristic for when doccoms are similar enough to be duplicates seems like an invitation for kludges.

@cloudRoutine
Copy link
Contributor Author

Is there anything else I need to do for this?

@cloudRoutine
Copy link
Contributor Author

this might even encourage people to spend more time writing documentation in signature files since they'd actually get the benefit of it in their implementation files. the giant gross xml doccoms won't have to pollute their code.

@cartermp
Copy link
Contributor

@cloudRoutine agreed

@cloudRoutine
Copy link
Contributor Author

@KevinRansom this'll be pretty useful when working on the parts of the compiler where there's extensive documentation in the signatures but barely any in the implementation files. So hopefully it can get merged soon.

@cloudRoutine
Copy link
Contributor Author

@KevinRansom all green and resolved here too

@cloudRoutine
Copy link
Contributor Author

integrated into #2683

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

Successfully merging this pull request may close these issues.

6 participants