dmy / elm-doc-preview

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

Import from submodule outside the src directory #8

Closed Markloev closed 5 years ago

Markloev commented 5 years ago

I currently have a submodules folder on the same level of the src directory that has modules I need to import for components in the src directory, but this is throwing the 'When creating a package, all modules must live in the src/ directory.' error. Is this something that you will be able to fix?

rlefevre commented 5 years ago

I'm not sure to understand how elm-doc-preview is involved. Are you able to compile your package ?

elm-doc-preview will simply run elm make --docs=/tmp/docs.json in the directory where it is started (or the one passed as an optional argument). Are you able to run this command manually?

Markloev commented 5 years ago

So we have an internal package that we use in all of our apps through submodules. We forked elm-menu and included that code directly into our apps as well through submodules because it was causing issues with the elm-debugger installing it through elm-package.

So in our apps we include our internal package which has an AutoComplete module that uses elm-menu.

The internal package compiles because in all of our apps we include both our internal package and elm-menu through submodules and we put those directories from the submodules/ folder in our source-directories list in elm.json

but when we try to generate the docs, there is no way to have a src-directories option in the elm.json of the package to tell it to import Menu from submodules/elm-menu/src so we get a compile error when generating the docs.

rlefevre commented 5 years ago

I see, however this is a constraint of elm make with packages, not specific to elm-doc-preview. So I won't be able to do anything about it in elm-doc-preview.

Anyway, here are two ideas to solve your issue:

  1. if your forked elm-menu kept exactly the same API (with some implementation changes) as the official one, then you can build your auto-complete package documentation with the official elm-menu as a dependency, because when applications are compiled, they will rebuild the package anyway without using its elm.json (the package is just an additional source directory of the app).
  2. If 1 is not possible and if you never use the forked elm-menu alone without you internal auto-complete, you could merge the two in a single submodule. So the auto-complete module will be able to compile in standalone.
rlefevre commented 5 years ago

elm-doc-preview has no way to change elm make behavior, so I will close this issue.