Module: Docify

Defined in:
lib/docify/style.rb,
lib/docify/format.rb,
lib/docify/markup.rb,
lib/docify/version.rb,
lib/docify/document.rb,
lib/docify/template.rb

Defined Under Namespace

Modules: Markup Classes: Document, Template

Constant Summary collapse

TEMPLATE =
"<!DOCTYPE html> \n<html>\n  <head>\n    <title>{{title}}</title>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /> \n    {{css}}\n  </head>\n  <body>\n    <div id=\"content\">{{content}}</div>\n  </body>\n</html>\n"
CSS =
"<style>\n  body {\n    background: #f8f8f8;\n    font: 13.34px helvetica,arial,freesans,clean,sans-serif;\n  }\n  \n  body * { line-height: 1.4em; }\n  \n  a { color: #4183C4; text-decoration: none; }\n  a:hover { text-decoration: underline; }\n  \n  #content {\n    width: 800px; margin: 0px auto;\n  }\n  \n  p {\n    margin: 1em 0!important;\n    line-height: 1.5em!important;\n  }\n  \n  h1, h2, h3, h4, h5, h6 { border: 0 !important; }\n  \n  h1 {\n    font-size: 170%!important;\n    border-top: 4px solid #AAA!important;\n    padding-top: .5em!important;\n    margin-top: 1.5em!important;\n  }\n  \n  h1:first-child { border-top: none !important; }\n  \n  h2 { \n    font-size: 150% !important;\n    margin-top: 1.5em !important;\n    border-top: 4px solid #E0E0E0 !important;\n    padding-top: .5em !important;\n  }\n  \n  h3 { margin-top: 1em !important; }\n  \n  pre, code {\n    font: 12px 'Bitstream Vera Sans Mono','Courier',monospace;\n  }\n  \n  pre {\n    margin: 1em 0;\n    font-size: 12px;\n    background-color: #eee;\n    border: 1px solid #ddd;\n    padding: 5px;\n    line-height: 1.5em;\n    color: #444;\n    overflow: auto;\n    -webkit-box-shadow: rgba(0,0,0,0.07) 0 1px 2px inset;\n    -webkit-border-radius: 3px;\n    -moz-border-radius: 3px;\n    border-radius: 3px;\n  }\n  \n  code {\n    font-size: 12px !important;\n    background-color: ghostWhite !important;\n    color: #444 !important;\n    padding: 0 .2em !important;\n    border: 1px solid #DEDEDE !important;\n  }\n  \n  pre code {\n    padding: 0!important;\n    font-size: 12px!important;\n    background-color: #EEE!important;\n    border: none!important;\n  }\n</style>\n"
FORMATS =

All supported formats

['rdoc', 'markdown', 'textile']
ALIASES =

Aliases for file extensions

{
  '.rdoc'     => 'rdoc',
  '.textile'  => 'textile',
  '.markdown' => 'markdown',
  '.md'       => 'markdown'
}
VERSION =
'1.0.3'.freeze

Class Method Summary collapse

Class Method Details

.detect_format(file) ⇒ Object

Automatically detect format from extension



19
20
21
22
# File 'lib/docify/format.rb', line 19

def self.detect_format(file)
  ext = File.extname(file).downcase
  ALIASES.key?(ext) ? ALIASES[ext] : FORMATS.first
end

.valid_format?(f) ⇒ Boolean

Returns true if provided format is supported

Returns:

  • (Boolean)


14
15
16
# File 'lib/docify/format.rb', line 14

def self.valid_format?(f)
  FORMATS.include?(f)
end