fsprojects / FSharp.Formatting

F# tools for generating documentation (Markdown processor and F# code formatter)
https://fsprojects.github.io/FSharp.Formatting/
Other
462 stars 155 forks source link

Format #747

Closed nojaf closed 2 years ago

nojaf commented 2 years ago

Hi @dsyme, fantomas-tool was renamed to fantomas so you didn't bump to the latest version.

dsyme commented 2 years ago

Hi @dsyme, fantomas-tool was renamed to fantomas so you didn't bump to the latest version.

I see!!!! No wonder I hadn't seen the latest versions :)

dsyme commented 2 years ago

Thank you!!

nhirschey commented 2 years ago

Were the deletions of // FSX and // IPYNB from #endif // FSX conditionals intended? If I leave off // FSX then the #endif is left in the output .fsx file.

For example:

(***condition:fsx***)
#if FSX
let a = 4
#endif

results in an output .fsx with:

let a = 4
#endif

Is this from fantomas?

nojaf commented 2 years ago

Fantomas does appear not to restore the comment after a hash directive. Sample.

dsyme commented 2 years ago

They weren't intended. @nojaf Did you create a tracking issue for this in fantomas?

dsyme commented 2 years ago

Fixed for this repo via a .fantomasignore entry

https://github.com/fsprojects/FSharp.Formatting/pull/751

nojaf commented 2 years ago

@dsyme, no I didn't. I'm a bit confused here, is this relevant or not? If there is meaning to the comment after the hash directive, if can't help but feel that this solution should be reviewed instead. Fixing this in Fantomas will introduce a messy solution. You want to assign a trivia to a trivia here. This little manoeuvre won't be pretty and probably introduce a performance hit for everybody. I'd like to know more before trying to address this on Fantomas' side. This feels very unorthodox, to be frank.

dsyme commented 2 years ago

Hmmm, I suspect it's quite common to have clarifying comments in this position, I know I do it all the time to clarify what the #endif is closing. We should probably open a fantomas issue and discuss there even if you decide not to fix, so there's a record of it.

In this case yes, there's a meaning of sorts for the somewhat hacky pre-processing of the scripts (that however could likely be implemented in other ways)

nojaf commented 2 years ago

This will be painful if we need to check this in larger files: example.

Every comment after source code that is not yet assigned should be checked against hash directives. This feels like it should be an IDE hint feature instead. I'm open to discussing this further on Fantomas' side.