Module: Brief
- Defined in:
- lib/brief/document/structure.rb,
lib/brief.rb,
lib/brief/dsl.rb,
lib/brief/apps.rb,
lib/brief/data.rb,
lib/brief/model.rb,
lib/brief/version.rb,
lib/brief/document.rb,
lib/brief/briefcase.rb,
lib/brief/repository.rb,
lib/brief/configuration.rb,
lib/brief/server/socket.rb,
lib/brief/model/definition.rb,
lib/brief/model/persistence.rb,
lib/brief/document/rendering.rb,
lib/brief/document/attachments.rb,
lib/brief/document/transformer.rb,
lib/brief/document/front_matter.rb,
lib/brief/briefcase/documentation.rb,
lib/brief/document/content_extractor.rb,
lib/brief/cli/01_extensions.rb
Overview
# Structured Documents
Normal markdown is rendered flat. While there may be hierarchy, it was difficult to parse it in a way which made the headings collapsible.
The Document Structure is responsible for grouping blocks of content under their nearest previous heading element acting as a parent. It does this by wrapping them in ‘<section>` and <article> tags, and through the use of data-attributes on the elements.
“‘
-
h1
-
h2
-
h3
-
h3
-
-
h2
-
-
h1
-
h2
-
“‘
This class allows for us to define rules based on headings, for how we might interpret the meaning of the content that is written. It allows us to say: all level 2 headings are ‘TodoItems’ if they exist under the level 1 heading ‘Tasks’
Defined Under Namespace
Modules: Adapters, DSL, Data, DocumentMapper, Model, Util Classes: Apps, Briefcase, Configuration, Document, Repository, Server
Constant Summary collapse
- VERSION =
'1.11.0'
Class Method Summary collapse
-
.activate_adapter(identifier) ⇒ Object
Adapters for Rails, Middleman, or Jekyll apps.
- .apps_path ⇒ Object
- .case(fire = false) ⇒ Object
- .case=(value) ⇒ Object
- .cases ⇒ Object
- .configuration ⇒ Object
- .default_cli_options(c) ⇒ Object
- .default_model_class ⇒ Object
- .environment_info ⇒ Object
- .lib_root ⇒ Object
- .load_commands ⇒ Object
- .load_modules_from(folder) ⇒ Object
-
.pwd ⇒ Object
When packaging this up through the traveling ruby system Dir.pwd is not accurate because of the wrapper.
- .views ⇒ Object
Class Method Details
.activate_adapter(identifier) ⇒ Object
Adapters for Rails, Middleman, or Jekyll apps
98 99 100 101 102 103 |
# File 'lib/brief.rb', line 98 def self.activate_adapter(identifier) require "brief/adapters/#{ identifier }" (Brief::Adapters.const_get(identifier.camelize) rescue nil).tap do |adapter| raise "Invalid adapter: #{ identifier }" unless adapter end end |
.apps_path ⇒ Object
65 66 67 |
# File 'lib/brief.rb', line 65 def self.apps_path lib_root.join("..","apps") end |
.case(fire = false) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/brief.rb', line 32 def self.case(fire=false) if @briefcase.is_a?(Brief::Briefcase) @briefcase elsif fire && @briefcase.respond_to?(:call) @briefcase = @briefcase.call() else @briefcase end end |
.case=(value) ⇒ Object
26 27 28 |
# File 'lib/brief.rb', line 26 def self.case=(value) @briefcase = value end |
.cases ⇒ Object
22 23 24 |
# File 'lib/brief.rb', line 22 def self.cases @cases ||= {} end |
.configuration ⇒ Object
57 58 59 |
# File 'lib/brief.rb', line 57 def self.configuration Brief::Configuration.instance end |
.default_cli_options(c) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/brief/cli/01_extensions.rb', line 34 def self.(c) c.option '--root DIRECTORY', String, 'The root for the briefcase' c.option '--config FILE', String, 'Path to the config file for this briefcase' c.option '--config-filename', String, 'The default filename for a briefcase config: brief.rb' c.option '--output FILE', String, 'Save the output in the specified path' c.option '--format FORMAT', String, 'How to format the CLI output: defaults to printed, accepts printed,json' c.option '--prefix-output CONTENT', String, 'Prefix the generated output with the following content' end |
.default_model_class ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/brief.rb', line 82 def self.default_model_class if defined?(Brief::DefaultModel) Brief::DefaultModel else Brief.const_set(:DefaultModel, Class.new { include Brief::Model; def self.type_alias; "default"; end }) end end |
.environment_info ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/brief.rb', line 46 def self.environment_info { VERSION: Brief::VERSION, lib_root: Brief.lib_root.to_s, apps: { search_paths: Brief::Apps.search_paths.map(&:to_s), available: Brief::Apps.available_apps } } end |
.lib_root ⇒ Object
61 62 63 |
# File 'lib/brief.rb', line 61 def self.lib_root Pathname(File.dirname(__FILE__)) end |
.load_commands ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/brief.rb', line 69 def self.load_commands Dir[lib_root.join('brief', 'cli', '**/*.rb')].each { |f| require(f) } # Each Brief::Model can define certain "actions" which can be called on the documents. # # The Brief CLI interface lets users dispatch these actions to the documents specified by the PATH args. Brief::Model.classes.each do |klass| Array(klass.defined_actions).uniq.each do |action| Brief::Util.create_method_dispatcher_command_for(action, klass) end end end |
.load_modules_from(folder) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/brief.rb', line 90 def self.load_modules_from(folder) Dir[folder.join('**/*.rb')].each do |f| #puts "Loading model from #{ f }" require(f) end end |
.pwd ⇒ Object
When packaging this up through the traveling ruby system Dir.pwd is not accurate because of the wrapper. We shim it by setting a special ENV variable in that file
18 19 20 |
# File 'lib/brief.rb', line 18 def self.pwd ENV.fetch('BRIEF_PWD') { Dir.pwd } end |
.views ⇒ Object
42 43 44 |
# File 'lib/brief.rb', line 42 def self.views @views ||= {} end |