dmy / elm-doc-preview

Elm offline documentation previewer
https://www.npmjs.com/package/elm-doc-preview
Other
127 stars 15 forks source link

A better default for the application name #37

Open Kurren123 opened 4 years ago

Kurren123 commented 4 years ago

Following from the discussion here:

a nice default for the name would be user_name/dir where dir is the name of the directory containing the elm.json file, as I think this directory is usually a kind of project name

@rlefevre replied with:

The potential issue with that is that sometimes the elm app is in a sub-directory of the project. For example, for one of my Elixir/Phoenix app, the elm application is in assets/elm, so the application would be named my/elm

Thinking about this, maybe if the default is no good you would then specify the name in the application.json? I'm just trying to think of what happens in the majority of cases. I think most of the time the elm.json file sits in the root directory which has a kind of application name. But I think we probably need more opinions here.

Also from @rlefevre:

Another issue is that there are a lot more restrictions on package names that directory names (and the application is transformed to a package before generating the documentation). A lot of characters are forbidden, and a few more rules.

Perhaps we could transform the directory name into something friendly?

rlefevre commented 4 years ago

Note that user names rules are here: https://github.com/shinnn/github-username-regex

According to the form validation messages on Join Github page,

For the module names, they are here: https://github.com/elm/compiler/blob/38670361cd4b9f9f09621f3f5a7dbe07ebde7bf2/compiler/src/Elm/Package.hs#L316

So from a quick glance:

rlefevre commented 4 years ago

For user_name/dir, were you thinking about the logged-in user for the user name? This would make sense.

Apparently, it is be available cross-plaform with: https://nodejs.org/api/os.html#os_os_userinfo_options.

rlefevre commented 4 years ago

Perhaps we could transform the directory name into something friendly?

We could indeed, I have put above the restrictions to respect.

I agree that the combination OS_user/current_directory should be more useful than my/application for the large majority of cases.