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

Custom output directory as command line flag #51

Closed
HugoGranstrom opened this issue May 27, 2021 · 2 comments
Closed

Custom output directory as command line flag #51

HugoGranstrom opened this issue May 27, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@HugoGranstrom
Copy link
Collaborator

This is something that we have had to do workarounds for in nimiBook, the fact that we don't want the output .html and images to be beside the .nim files. In that case, we would like to be able to set an output directory relative to the Nimble project but it still feels a bit like jumping through hoops because we must make sure the srcDir, homeDir, etc match up to what we expect. (may not be anymore though:P)

And this is also useful for nimiBoost so that one can compile and preview single .nim files that are located in a nimble project without having to care about the fact that it is in a nimble directory. I, therefore, suggest that we find a way to make it easier to choose these in the compile command already.

The needs I have for the nimiBoost extension is to set the output dir primarily, if it has an ugly name in the header I don't care about but if it too could be fixed that would be great.

From my research the easiest approach seems to be {.strdefine.} variables https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-compileminustime-define-pragmas . For example

const nbHomeDir {.strdefine.} = ""
when not defined(nbHomeDir):
  nbHomeDir = findNimbleDir(nbThisDir)

This won't run of course but it conveys the main idea. when compiling the file we could then pass in a directory like this -d:nbHomeDir=McDonalds/BurgerKing and if it isn't defined we use the nimble dir.

Do you see any obvious flaws with this approach?

@pietroppeter
Copy link
Owner

I do want to revise in general how paths are handled in nimib, since as we have abundantly seen in nimibook, current choices are not... great. Some kind of compile time switch on top of that to override whatever defaults we end up with could also be a good idea (I also like strdefine). Ideally I would like to revise everything first, but not to let the "better be the enemy of the good", if you come up with a working implementation for this I would proceed with a merge and release.

Ah, regarding nimiBoost, you should open up the issues, I have a suggestion/remark to do there. :)

@pietroppeter pietroppeter added the enhancement New feature or request label Jun 2, 2021
@HugoGranstrom
Copy link
Collaborator Author

I do want to revise in general how paths are handled in nimib, since as we have abundantly seen in nimibook, current choices are not... great. Some kind of compile time switch on top of that to override whatever defaults we end up with could also be a good idea (I also like strdefine). Ideally I would like to revise everything first, but not to let the "better be the enemy of the good", if you come up with a working implementation for this I would proceed with a merge and release.

Yes a revised Nimib would be the ultimate solution :) But I think it wouldn't be too much work fixing a patch in the mean-time so I'll see what I can do. Any suggestions for the variable name to assign the string to? (nbHomeDir is a AbsoluteDir and not a string so can't assign it directly)

Ah, regarding nimiBoost, you should open up the issues, I have a suggestion/remark to do there. :)

Done! Didn't even notice it wasn't open 🙃 All improvements are welcome 😄

pietroppeter added a commit that referenced this issue Nov 6, 2021
* instead of creating and injecting multiple variables
  (`nbDoc`, `nbBlock`, `nbHomeDir`, ...), nimib now only injects a `nb` variable
  that is a `NbDoc`. Some aliases are provided to minimize breakage.
* handling of paths (`srcDir` and `homeDir`) is changed and is based on the presence
  of a new config file `nimib.toml`
* command line options are now processed and can be used to skip/override the config process.
  Run any nimib file with option `--nbHelp` to see available options.
* `nbPostInit` and `nbPreSave` customization mechanism based on includes are now removed 
* added `nbShow` command option to open in browser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants