From cc53b6fbef856803c35f7dbdbe6bcdba98d265e9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 22 Jan 2014 10:30:25 -0800 Subject: [PATCH] :memo: Doc Syntax class --- src/syntax.coffee | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/syntax.coffee b/src/syntax.coffee index ac5edb3e0..af1a6278a 100644 --- a/src/syntax.coffee +++ b/src/syntax.coffee @@ -6,7 +6,12 @@ _ = require 'underscore-plus' {$, $$} = require './space-pen-extensions' Token = require './token' -### Public ### +# Public: Syntax class holding the grammars used for tokenizing. +# +# The Syntax class also contains properties for things such as the +# language-specific comment regexes. +# +# There is always a syntax object available under the `atom.syntax` global. module.exports = class Syntax extends GrammarRegistry Subscriber.includeInto(this) @@ -49,6 +54,18 @@ class Syntax extends GrammarRegistry @scopedProperties = [] @scopedPropertiesIndex = 0 + # Public: Get a property for the given scope and key path. + # + # ## Example + # ```coffee + # comment = atom.syntax.getProperty(['.source.ruby'], 'editor.commentStart') + # console.log(comment) # '# ' + # ``` + # + # * scope: An {Array} of {String} scopes. + # * keyPath: A {String} key path. + # + # Returns a {String} property value or undefined. getProperty: (scope, keyPath) -> for object in @propertiesForScope(scope, keyPath) value = _.valueForKeyPath(object, keyPath)