Git Product home page Git Product logo

Comments (15)

evancz avatar evancz commented on August 18, 2024

This is weird. The cause is almost certainly in this file, but I wasn't able to figure it out yet. Are you able to take a look?

from package.elm-lang.org.

mgold avatar mgold commented on August 18, 2024

I'd love to but I can't get the package built. I'll open a thread on the list for visibility.

Also, I found Keyboard.keysDown as Signal Set KeyCode) which means it's dropping open parens not related to the unit type.

from package.elm-lang.org.

evancz avatar evancz commented on August 18, 2024

Oh, that's an intriguing hint! Can you record the exact typos you find by editing the initial issue? Collecting the exact text in one place will help us see patterns.

from package.elm-lang.org.

evancz avatar evancz commented on August 18, 2024

!!! I think I got it. I added some code to drop qualifiers, but I think it is too naive and will group the parens with the qualifier. I think that's what's happening in the Signal Set KeyCode) example at least. I don't see how it explains the unit case though.

I bet this code explains part of things. Can you try that out just in a small file and feed it strings to see what it does? May not be necessary to build everything!

from package.elm-lang.org.

mgold avatar mgold commented on August 18, 2024

That reproduces the problem for Keyboard.keysDown but not Signal (). It will also turn Set.Set Time.Time into Time (except there's a words upstream).

One option is to uses regexes:

dropQualifier : String -> String
dropQualifier token =
  let qualifiers = Regex.regex "[A-Za-z1-9_]*[.]"
  in Regex.replace Regex.All qualifiers (always "") token

I dug through the parser code and I think I figured out what matches valid module names. Also "\." is rejected as a regex so to match the dot I had to put it in angle brackets. The regex even handles crazy but valid types like Time.Time -> Graphics.Element.Element without any string splitting.

The string splitting solution is a bit involved - I've inlined the String.words here -

dropQualifier : String -> String
dropQualifier tipe =
  String.words tipe
  |> List.map (String.split ".")
  |> List.map (\tokens ->
    case tokens of
      [] -> ""
      [x] -> x
      x::xs -> if String.startsWith "(" x
               then String.cons '(' (last xs |> Maybe.withDefault "")
               else last xs |> Maybe.withDefault "")
  |> String.join " "

I'm happy to PR whichever one you like but I prefer the regex, especially if you can be more certain I'm not leaving modules behind.

from package.elm-lang.org.

evancz avatar evancz commented on August 18, 2024

Nice, I like the regex one better too, can you do a PR for that?

One thing to think about is that module names can be any unicode, so it may make sense to use something like this but that actually does not exist in JS :( The other thing is that because you are in a string, you need to double escape things: \n is a newline in a string, whereas \\n is going to show up to the user as \n. For some reason the JS stuff needs it as \\. I think.

from package.elm-lang.org.

mgold avatar mgold commented on August 18, 2024

Have you confirmed this fixes the issue?

from package.elm-lang.org.

evancz avatar evancz commented on August 18, 2024

Oh, oops! Yes, it's live on the site too!

from package.elm-lang.org.

mgold avatar mgold commented on August 18, 2024

Okay, I see that Keyboard.keysDown is fixed but all the unit types are still broken.

from package.elm-lang.org.

mgold avatar mgold commented on August 18, 2024

The error is server-side. If you look at the JSON file being sent when loading a docs page, unit types are already missing the open paren. Example with Task.Task x ).

from package.elm-lang.org.

evancz avatar evancz commented on August 18, 2024

If you run elm-make --docs whatever.json on your code, does that output have the issue? Or is this something I introduced when migrating the old docs to new docs?

from package.elm-lang.org.

evancz avatar evancz commented on August 18, 2024

If the migration introduced it, the fastest / best fix may be to find type fields with an uneven number of parens and fix them by hand.

from package.elm-lang.org.

mgold avatar mgold commented on August 18, 2024

Running the docs locally produces the correct output. As confirmation, we see the issue in core (Mouse.clicks) even though it hasn't been updated recently. But I'm not sure the migration is at fault either, since I also see the issue on libraries uploaded today.

I dug through the server and it seems to just serve the json file. Can you have a look at the actual file on disk (like the example in my last post) and see if the problem is there?

Also, reopen the issue?

from package.elm-lang.org.

evancz avatar evancz commented on August 18, 2024

Okay, I think I went and fixed all the old things. Can you confirm that these things are gone?

If it is true that "elm-make --docs" is working okay then we should be done. If not, we have narrowed things down a bit!

from package.elm-lang.org.

mgold avatar mgold commented on August 18, 2024

Yup, looks like things are fixed and the new docs generator is working. Thanks!

from package.elm-lang.org.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.