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

Hologram always assumes ERB files should be executed #123

Closed
adamsanderson opened this issue Jun 3, 2014 · 9 comments
Closed

Hologram always assumes ERB files should be executed #123

adamsanderson opened this issue Jun 3, 2014 · 9 comments

Comments

@adamsanderson
Copy link

This might be a bit tricky to get right, but it appears that as of v1.1.0, Hologram assumes that any ERB file should be executed to generate a page in the style guide.

This probably makes sense if you're using it to generate a sample JSON file to give some JS something to play with, but it breaks Rails assets that use ERB. For instance, one might have a file like sprites.css.erb, which is a CSS file that relies on Rails helpers.

If any files like this exist in the directory specified by source in the yaml config, Hologram will either generate a sprites.css file in destination directory, or crash if the file needs any Rails helpers.

Perhaps Hologram's DocBuilder could only call write_erb if the file looks like it's either a straight ERB file, ie: readme.erb or an html erb file like readme.html.erb, and just document the file otherwise.

@jdcantrell
Copy link
Contributor

Ah thanks for the info.

We might be able to handle this using some config flags. I'll think about this for a little while and see if we can get a point release with a fix this week,

Config idea for now:

process_erb_files: true
exclude_erb:
 - sprice.css.erb

By default we would not process erb files, but if the config flag is set we will process everything that is not listed in the excludes list.

@adamsanderson
Copy link
Author

You could also probably add an exclude_processing option that takes a glob, ie:

exclude_processing: *.{css,js}.erb

Then test it with File.fnmatch(glob, path).

@jdcantrell
Copy link
Contributor

Went with:

ignore_paths:
  - "*.erb"
  - my_file.scss

@jdcantrell
Copy link
Contributor

Went with:

ignore_paths:
  - "*.erb"
  - my_file.scss

1 similar comment
@jdcantrell
Copy link
Contributor

Went with:

ignore_paths:
  - "*.erb"
  - my_file.scss

@adamsanderson
Copy link
Author

Hey, thanks for taking care of this.

@jdcantrell
Copy link
Contributor

NP! Sorry for the triple comment, not sure what I was doing when that happened.

@wwcline
Copy link

wwcline commented Apr 22, 2016

Adding the ignore_paths option in #213 solves the problem where you don't want Hologram to treat every ERb as if it were a style guide page, but it also seems to prevent Hologram from processing documentation blocks inside ERb files.

For instance, one might have a file like sprites.css.erb, which is a CSS file that relies on Rails helpers.

In my case, I have .css.erb files that contain documentation blocks. Hologram is processing the ERb and putting files like sprites.css in my output directory. I can stop that behavior by setting ignore_paths but in neither case will sprites.css.erb’s documentation blocks appear anywhere in the output pages.

@wwcline
Copy link

wwcline commented Apr 22, 2016

The problematic code seems to be this:

https://github.com/trulia/hologram/blob/master/lib/hologram/doc_parser.rb#L89

Am I correct in understanding that *.erb files will never be scanned for documentation blocks, as Hologram works currently?

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

No branches or pull requests

3 participants