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

Some features adjustment on MetadataFormat #64

Merged
merged 4 commits into from
Nov 11, 2013

Conversation

soloman817
Copy link
Contributor

I modified these issues:

  • Added F# special member for type: UnionCase and RecordField, they are listed as members in Type;
  • Make some change in displaying the members' usage (all because in real project, TypeName usually is very long):
    • For constructor, use "new(arg1, arg2, ...)" instead of "new TypeName" because in real project, TypeName usually is very long.
    • For instance members, discard the instance name, just show the method name and its arguments;
    • For static methods, discard the type name.
  • Modifed the templates to show the special members of type, and also list nested types in module.

I also find another bug, that the private constructor is also listed. I traced this problem and find that it is a FSharpPowerPack.Metadata problem, so I also make a FSharpPowerPack repo, and fixed it by just one line, you can check that here: soloman817/FSharpPowerPack@05182d5

@tpetricek
Copy link
Member

Wow, great work!! :-) I'll test & merge this tomorrow.

@soloman817
Copy link
Contributor Author

Hi Tomas,

Good you like it. Here is the manual I build for Alea.cuBase:
http://www.aleacubase.com/temp/manual/

You can click the "Reference" link to see the doc generated by my
modification of your formating library.

To apply the fixed PowerPack.Metadata.dll, you can clone my repo and just
build the PowerPack.Metadata.dll and then replace the one in fsformatting
project.

Regards,
Xiang.

On Fri, Nov 8, 2013 at 1:22 PM, Tomas Petricek notifications@github.comwrote:

Wow, great work!! :-) I'll test & merge this tomorrow.


Reply to this email directly or view it on GitHubhttps://github.com//pull/64#issuecomment-28036656
.

@soloman817
Copy link
Contributor Author

example of union case:
http://www.aleacubase.com/temp/manual/reference/alea_cuda/alea-cuda-common-compileerror.html

example of record fields:
http://www.aleacubase.com/temp/manual/reference/alea_cuda/alea-cuda-common-compileoptions.html

example of nested types:
http://www.aleacubase.com/temp/manual/reference/alea_cuda/alea-cuda-engine.html

On Fri, Nov 8, 2013 at 1:22 PM, Tomas Petricek notifications@github.comwrote:

Wow, great work!! :-) I'll test & merge this tomorrow.


Reply to this email directly or view it on GitHubhttps://github.com//pull/64#issuecomment-28036656
.

@tpetricek
Copy link
Member

Nice! I'm glad other people are finding F# formatting useful. I'll run this on the Deedle documentation (which has some records & discriminated unions) too. Thanks very much for the contribution!

@soloman817
Copy link
Contributor Author

Thank you providing such a good tool. This is the best one for F# :)

On Fri, Nov 8, 2013 at 3:21 PM, Tomas Petricek notifications@github.comwrote:

Nice! I'm glad other people are finding F# formatting useful. I'll run
this on the Deedle documentation (which has some records & discriminated
unions) too. Thanks very much for the contribution!


Reply to this email directly or view it on GitHubhttps://github.com//pull/64#issuecomment-28041771
.

@ovatsus
Copy link

ovatsus commented Nov 8, 2013

Cool, if I read this right, it will allow to document JsonValue properly in FSharp.Data

tpetricek added a commit that referenced this pull request Nov 11, 2013
Some features adjustment on MetadataFormat
@tpetricek tpetricek merged commit dbc9702 into fsprojects:master Nov 11, 2013
@tpetricek
Copy link
Member

Released in version 2.2.7-beta (labeled as beta mainly because I made some other unrelated beta changes on my machine - it should not break anything, but who knows :-))

I also have not imported the changes in PowerPack yet - I'm wondering what's the best way to do that. Perhaps we should just copy the code from PowerPack and have it directly in the repository here? (I think it is unlikely that anyone else would want to maintain that...) Thoughts @ovatsus @dsyme @forki?

@forki
Copy link
Member

forki commented Nov 11, 2013

If there is no license problem, then I'd suggest copy it over.

@forki
Copy link
Member

forki commented Nov 11, 2013

image

I'm getting an invalid cast exception. Ideas?

fsprojects/FAKE@95725d4

@soloman817
Copy link
Contributor Author

This seems to be a Razor template problem, you need a little trace into the
template, I think you might used a customized template, right?

Also, I think I forgot one thing, if there is a generic type (not nested),
the template should do HTML encoding like
@Html.Encode(typeName)
Because generic type name contains "<"

On Mon, Nov 11, 2013 at 6:13 PM, Steffen Forkmann
notifications@github.comwrote:

[image: image]https://f.cloud.github.com/assets/57396/1511807/de175594-4ab9-11e3-8c04-3891e2eb6d74.png

I'm getting an invalid cast exception. Ideas?


Reply to this email directly or view it on GitHubhttps://github.com//pull/64#issuecomment-28187408
.

@soloman817
Copy link
Contributor Author

So for example, I used following razor template in my project (not in this pull request):

            <ul class="nav nav-list" id="menu">
                @(((IDictionary<string, string>)ViewBag.Properties)["nav-list"])
            </ul>

So, from your error screenshot, you are reading view bag Properties, you should use correct cast I think.

@ovatsus
Copy link

ovatsus commented Nov 11, 2013

I'd also suggest that you just copy the file from powerpack

@forki
Copy link
Member

forki commented Nov 11, 2013

@soloman817 I get the same error with the default templates

@soloman817
Copy link
Contributor Author

could you send the dll to me via soloman817@gmail.com

@forki
Copy link
Member

forki commented Nov 11, 2013

It might be easier to clone fsprojects/FAKE@95725d4 and run build.cmd

@soloman817
Copy link
Contributor Author

ok, let me have a try.

On Mon, Nov 11, 2013 at 7:19 PM, Steffen Forkmann
notifications@github.comwrote:

It might be easier to clone fsprojects/FAKE@95725d4fsprojects/FAKE@95725d4and run build.cmd


Reply to this email directly or view it on GitHubhttps://github.com//pull/64#issuecomment-28190953
.

@soloman817
Copy link
Contributor Author

@forki I confirmed, this problem is because you used things like @Root or @Properties in your template.

Here is the step I debug this problem:

  • I replaced every place in your templates that has:
    • @Root
    • @Properties[...]
    • Properties[...]

Then I can pass the build, but once if I added a @Root then it will fail.

I think I also met this problem when using Properties, in my code I have to use this ugly code:
@(((IDictionary<string, string>)ViewBag.Properties)["nav-list"])

Because I traced into the code, the Properties is created as a dictionary, but must cast it down. Well I'm not very good at dynamic .NET, could @tpetricek check this? I think this is not a problem raised by my commits, this is about how to use the dynamic view bag stuff in the template which I'm not very familiar.

Regards,
Xiang.

@tpetricek
Copy link
Member

I'll have a look. Razor is quite odd, but I think it might be fixed if I change how the dictionaries are created.

@ovatsus
Copy link

ovatsus commented Nov 18, 2013

I updated FSharp.Data to 2.2.7-beta, but I'm still not getting the Union Cases section in JsonValue, even after manually changing types.cshtml to include them (https://github.com/fsharp/FSharp.Data/blob/master/docs/tools/reference/type.cshtml#L16)
What am I missing?
I also don't get any razor related problem

@ovatsus
Copy link

ovatsus commented Nov 19, 2013

@soloman817 How do you specify the docs for the record fields in the source code to generate this (http://www.aleacubase.com/temp/manual/reference/alea_cuda/alea-cuda-common-compileoptions.html)
VS Intellisense doesn't seem to pick it up (see http://stackoverflow.com/questions/20016568/xml-documentation-for-interface-methods-and-record-properties)

@soloman817
Copy link
Contributor Author

@ovatsus The UnionCase is parsed by FSharp.PowerPack.Metadata, so it should be there, and make sure you use fsharp 3.0+ (by running the script with Developer Prompt VS2012 or 2013).

The following code generates this page

/// Compiling options.
type CompileOptions =
    {
        /// The module name. If a module is used as library, it _must_ be assigned with a module name.
        ModuleName : string
        AddressSize : AddressSize
        MinimalArch : DeviceArch
        VarDebug : bool
        FixInlineFunctionIssue : bool

        LinkageG : bool
        LinkageOpt : LinkageOpt
        LinkageFTZ : bool
        LinkagePrecSqrt : bool
        LinkagePrecDiv : bool
        LinkageFMA : bool

        JITMaxRegisters : int option
        JITCacheMode : JITCacheMode option
    }

Another example generate this page

/// CUDA JIT compiling cache mode.
type JITCacheMode =
    /// Compile with L1 cache disabled.
    | CG
    /// Compile with L1 cache enabled.
    | CA

But I'm using VS2012, don't know if it work with open source fsharp.

@tpetricek
Copy link
Member

@forki @soloman817 I tried reproducing the error mentioned above (when building FAKE) but it works fine with the latest master of FSharp.Formatting. Can you please open a separate issue if you get the above error again?

The latest master also includes union cases & records in AllMembers so it will work with the default templates.

The default templates use AllMembers to group things by categories. My earlier check-in (96f46d1) removed old version of the templates (that I was not using and not maintaining) but which included fix from @soloman817 to render the union cases/record members.

@soloman817 I would be happy to include a version of templates that do not use LINQ to group by categories, but I think I can only reasonably maintain one version - but if you can add them and add a MetadataFormat test that uses them, that would be perfect (if your project fits better with this simpler version of the templates).

@soloman817
Copy link
Contributor Author

@forki @tpetricek I remembered that the reproducing happens in one branch, not master. But yes, @forki you should open a new issues, and better write down how to reproduce this problem.

@tpetricek absolutely you should only maintain one template. The problem is I went to the wrong template from the beginning. I will adjust my project to using the LINQ one later.

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.

None yet

4 participants