Sha256: 350496e41c852e419575e4f246cd8cee28ee60221dcab117f67e9562bdaf9852

Contents?: true

Size: 698 Bytes

Versions: 8

Compression:

Stored size: 698 Bytes

Contents

module Dox
  module DSL
    module Syntax
      extend ActiveSupport::Concern

      def document(subject, &block)
        documentation = _subjects[subject] = Documentation.new(subject: subject)
        documentation.instance_eval(&block)
      end

      def const_missing(name)
        documentation = _subjects[infer_subject(name)]

        return super unless documentation

        Module.new do
          define_singleton_method :included do |base|
            base.metadata.merge! documentation.config
          end
        end
      end

      def infer_subject(name)
        name.to_s.underscore.to_sym
      end

      def _subjects
        @_subjects ||= {}
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dox-2.4.0 lib/dox/dsl/syntax.rb
dox-2.3.0 lib/dox/dsl/syntax.rb
dox-2.2.0 lib/dox/dsl/syntax.rb
dox-2.1.0 lib/dox/dsl/syntax.rb
dox-2.0.0 lib/dox/dsl/syntax.rb
dox-2.0.0.beta3 lib/dox/dsl/syntax.rb
dox-2.0.0.beta2 lib/dox/dsl/syntax.rb
dox-2.0.0.beta1 lib/dox/dsl/syntax.rb