trulia / hologram

A markdown based documentation system for style guides.
http://trulia.github.io/hologram
Other
2.16k stars 199 forks source link

Process YAML frontmatter in .md files #204

Closed redoPop closed 9 years ago

redoPop commented 9 years ago

Allows markdown files to be treated as doc blocks if they open with YAML.

Summary of change:

process_files now examines the contents of each .md file to see if its opening lines look like YAML. If so, the file's contents are added to the doc_block_collection.

Resolves #188 since title can be specified in the YAML configuration.

My own use case is producing a CSS code style guide alongside the pattern style guide – i.e., documentation that doesn't really belong in a Sass/scss file. Using .md files for this documentation also makes them readable directly in GitHub, which is a nice bonus.

jdcantrell commented 9 years ago

Sorry for the slow response this is really nice. I'm wondering if the yaml shouldn't have a key specific in the yaml to let hologram know it should parse the yaml and markdown.

jdcantrell commented 9 years ago

The idea being that you might have yaml+markdown for generating something else in your project and you wouldn't want hologram to try and create pages off it.

redoPop commented 9 years ago

Can do! How does this sound:

---
hologram: true
title:    (...etc.)
---

(Markdown body)
jdcantrell commented 9 years ago

I think it's good, I was trying to think of something else but that's probably the best option for now. Thanks again for the PR.

redoPop commented 9 years ago

Okidoke! I also added an additional fixture for a dummy "jekyll.md" file that doesn't meet the hologram: true test, and added info about the new key to the readme.

An idea: we could avoid the need for the hologram: true flag by looking for a combination of the keys title, name, and one of parent/category/categories in the YAML. That footprint seems fairly unique; if the markdown contains all three perhaps we can be reasonably confident we're looking at a Hologram configuration.