Directives are modifier comments that can appear after class, module,
 or method names. For example

   def fred    # :yields:  a, b

 or

   class SM  # :nodoc:

 we return the directive name and any parameters as a two element array
15333
def read_directive(allowed)
      tk = get_tk
      puts "directive: #{tk.inspect}" if $DEBUG
      result = nil
      if tk.kind_of?(TkCOMMENT) 
        if tk.text =~ /\s*:?(\w+):\s*(.*)/
          directive = $1.downcase
          if allowed.include?(directive)
            result = [directive, $2]
          end
        end
      else
        unget_tk(tk)
      end
      result
    end
503417
def directive_DCB(self, label, params):
        
        # TODO make this read only
        # TODO check for byte size
        self.labels[label] = self.space_pointer
        if params in self.equates:
            params = self.equates[params]
        self.memory[self.space_pointer] = self.convert_to_integer(params) & 0xFF
        self.space_pointer += 1
539305
function(name, cfg){
    if(!name) return;

    var type = typeof name;
    if(type === 'object' && !cfg){
      for(var k in name){
        if(name.hasOwnProperty(k)) this.directive(k, name[k]);
      }
      return this;
    }
    var directives = this._directives, directive;
    if(cfg == null){
      if( type === 'string' ){
        if( directive = directives[name] ) return directive;
        else{
          var regexp = directives.__regexp__;
          for(var i = 0, len = regexp.length; i < len ; i++){
            directive = regexp[i];
            var test = directive.regexp.test(name);
            if(test) return directive;
          }
        }
      }
    }else{
      if( typeof cfg === 'function') cfg = { link: cfg } 
      if( type === 'string' ) directives[name] = cfg;
      else{
        cfg.regexp = name;
        directives.__regexp__.push(cfg)
      }
      if(typeof cfg.link !== 'function') cfg.link = NOOP;
      return this
    }
  }
1131597
def _Tokenize(template_str, meta_left, meta_right, whitespace):
    """"""
    
    trimlen = len(meta_left)
    token_re = MakeTokenRegex(meta_left, meta_right)
    do_strip = (whitespace == 'strip-line')  # Do this outside loop
    do_strip_part = False
    
    for line in template_str.splitlines(True):  # retain newlines
        if do_strip or do_strip_part:
            line = line.strip()
        
        tokens = token_re.split(line)
        
        # Check for a special case first.  If a comment or "block" directive is on a
        # line by itself (with only space surrounding it), then the space is
        # omitted.  For simplicity, we don't handle the case where we have 2
        # directives, say '{.end} # {#comment}' on a line.
        if len(tokens) == 3:
            # ''.isspace() == False, so work around that
            if (tokens[0].isspace() or not tokens[0]) and \
                    (tokens[2].isspace() or not tokens[2]):
                token = tokens[1][trimlen: -trimlen]
                
                # Check the ones that begin with ## before #
                if token == COMMENT_BEGIN:
                    yield COMMENT_BEGIN_TOKEN, None
                    continue
                if token == COMMENT_END:
                    yield COMMENT_END_TOKEN, None
                    continue
                if token == OPTION_STRIP_LINE:
                    do_strip_part = True
                    continue
                if token == OPTION_END:
                    do_strip_part = False
                    continue
                
                if token.startswith('#'):
                    continue  # The whole line is omitted
                
                token_type, token = _MatchDirective(token)
                if token_type is not None:
                    yield token_type, token  # Only yield the token, not space
                    continue
        
        # The line isn't special; process it normally.
        for i, token in enumerate(tokens):
            if i % 2 == 0:
                yield LITERAL_TOKEN, token
            
            else:  # It's a "directive" in metachracters
                assert token.startswith(meta_left), repr(token)
                assert token.endswith(meta_right), repr(token)
                token = token[trimlen: -trimlen]
                
                # Check the ones that begin with ## before #
                if token == COMMENT_BEGIN:
                    yield COMMENT_BEGIN_TOKEN, None
                    continue
                if token == COMMENT_END:
                    yield COMMENT_END_TOKEN, None
                    continue
                if token == OPTION_STRIP_LINE:
                    do_strip_part = True
                    continue
                if token == OPTION_END:
                    do_strip_part = False
                    continue
                
                # A single-line comment
                if token.startswith('#'):
                    continue
                
                if token.startswith('.'):
                    literal = {
                        '.meta-left': meta_left,
                        '.meta-right': meta_right,
                        '.space': ' ',
                        '.tab': '\t',
                        '.newline': '\n',
                    }.get(token)
                    
                    if literal is not None:
                        yield META_LITERAL_TOKEN, literal
                        continue
                    
                    token_type, token = _MatchDirective(token)
                    if token_type is not None:
                        yield token_type, token
                
                else:  # Now we know the directive is a substitution.
                    yield SUBST_TOKEN, token
1317478
function parse( doxComment, options ) {
   if( !( 'ctx' in doxComment ) ) {
      doxComment.ctx = false;
   }

   const parsed = {
      // An explicitly given name is used in favor of a derived one.
      name: ( tagsByType( doxComment.tags, 'name', 'directive', 'injection', 'module' )[ 0 ] || {} ).string ||
         doxComment.ctx.name ||
         '- unknown -',
      description: description( doxComment ),
      dox: doxComment
   };

   const optional = [];
   parsed.params = tagsByType( doxComment.tags, 'param' )
      .map( tag => {
         const cleanName = tag.name.replace( /^\[?([^\]]*)]?$/g, '$1' );
         const parents = cleanName.split( '.' ).slice( 0, -1 );
         if( tag.optional ) {
            optional.push( cleanName );
         }
         else if( parents.some( p => optional.indexOf( p ) !== -1 ) ) {
            // a property of an optional object parameter is optional too
            optional.push( cleanName );
            tag.optional = true;
         }

         return {
            name: cleanName,
            types: tag.types.length === 0 ? [ '*' ] : tag.types,
            description: convertLineBreaks( description( tag ) ),
            dox: tag
         };
      } );

   parsed.paramsForArgsList = parsed.params
      // filter out object parameter properties for argument list
      .filter( param => param.name.indexOf( '.' ) === -1 )
      .map( param => param.name );

   parsed.returns = tagsByType( doxComment.tags, 'return', 'returns' )
      .map( tag =>
         ({
            name: tag.name,
            types: tag.types.length === 0 ? [ '*' ] : tag.types,
            description: convertLineBreaks( description( tag ) ),
            dox: tag
         })
      )[ 0 ] || null;

   if( options.verbose ) {
      /* eslint-disable no-console */
      console.log( JSON.stringify( parsed, null, 3 ) );
      /* eslint-enable no-console */
   }

   return parsed;
}
425636
function Directive(filename, directiveArguments) {
  this.filename = filename;
  this.name = directiveArguments[0].value;
  var directiveConfiguration = directiveArguments[1];
  // Extract the last attribute of the array
  if (directiveConfiguration.type === 'ArrayExpression' && directiveConfiguration.elements.length) {
    directiveConfiguration = directiveConfiguration.elements[directiveConfiguration.elements.length - 1];
  }
  // Parse the function
  if (directiveConfiguration && directiveConfiguration.type === 'FunctionExpression') {
    directiveConfiguration = esprimaHelper.getFirstReturnStatement(directiveConfiguration);
  }
  // Get the returnStatement
  if (directiveConfiguration && directiveConfiguration.type === 'ReturnStatement') {
    directiveConfiguration = directiveConfiguration.argument;
  }
  // Parse the object
  if (directiveConfiguration && directiveConfiguration.type === 'ObjectExpression') {
    var properties = esprimaHelper.parseObjectExpressions(directiveConfiguration);
    this.replace = !!properties.replace;
    this.transclude = !!properties.transclude;
    this.template = properties.template;
    this.templateUrl = properties.templateUrl;
    if (properties.restrict) {
      this.restrict = {
        A: properties.restrict.toUpperCase().indexOf('A') >= 0,
        E: properties.restrict.toUpperCase().indexOf('E') >= 0,
        C: properties.restrict.toUpperCase().indexOf('C') >= 0
      };
    }
  }
  // Add parse warning
  if (!this.restrict) {
    module.exports.logger('no restriction set for', this.filename, this.name);
    this.restrict = {
      A: true,
      E: false,
      C: false
    };
  }
}
988273
function addDirective(directiveName, dashCase, attrName, filterType, isBind, isBindOnce, isFilter) {
        app.directive(directiveName, ['i18n', 'config', function (i18n, config) {

            function setValue(scope, element, attrs, value) {
                value = !isFilter ? value :
                    filterType === 'file' ?
                        (config.staticFileRoot + value) :
                        i18n.translate(value, scope);

                attrName === 'text' ?
                    element.text(value) :
                    attrName === 'class' ?
                        attrs.$addClass(value) :
                        attrs.$set(attrName, value, scope);
            }

            return {
                priority: 101,
                link: function linkFn(scope, element, attrs) {
                    var originalValue = attrs[directiveName];

                    // if we are binding to the attribute value
                    if (isBind) {
                        var unwatch = scope.$watch(originalValue, function (value) {
                            if (value !== undefined && value !== null) {
                                setValue(scope, element, attrs, value);
                                if (isBindOnce && unwatch) { unwatch(); }
                            }
                        });
                    }

                    // else we are not binding, but we want to do some filtering
                    else if (!isBind && isFilter && filterType !== null) {
                        var fTextVal = (element && element.length && element[0].attributes &&
                            element[0].attributes[dashCase] && element[0].attributes[dashCase].value) || '';

                        // if the value contains {{ it means there is interpolation
                        if (fTextVal.indexOf('{{') >= 0) {
                            var unobserve = attrs.$observe(directiveName, function (value) {
                                setValue(scope, element, attrs, value);
                                if (isBindOnce && unobserve) { unobserve(); }
                            });
                        }
                        // else we are very simply setting the value
                        else {
                            setValue(scope, element, attrs, originalValue);
                        }
                    }
                    else {
                        throw new Error('Not bind nor filter in generic addDirective for ' + originalValue);
                    }
                }
            };
        }]);
    }
510704
def directive_DCH(self, label, params):
        
        # TODO make this read only
        # TODO check for word size

        # Align address
        if self.space_pointer % 2 != 0:
            self.space_pointer += self.space_pointer % 2
        self.labels[label] = self.space_pointer
        if params in self.equates:
            params = self.equates[params]
        for i in range(2):
            self.memory[self.space_pointer + i] = (self.convert_to_integer(params) >> (8 * i)) & 0xFF
        self.space_pointer += 2
821573
def [](new_size)
      if new_size.is_a? Directive
        tags.merge! new_size.tags_for_sized_directive
      else
        tags[:size] = new_size
      end

      self
    end
1223950
def parse_directive_location(lexer: Lexer) -> NameNode:
    """"""
    start = lexer.token
    name = parse_name(lexer)
    if name.value in .__members__:
        return name
    raise unexpected(lexer, start)
619087
def is_filter_with_outer_scope_vertex_field_operator(directive):
    """"""
    if directive.name.value != 'filter':
        return False

    op_name, _ = _get_filter_op_name_and_values(directive)
    return op_name in OUTER_SCOPE_VERTEX_FIELD_OPERATORS
677412
function directives() {
    var i, p, pn;

    for (;;) {
      if (state.tokens.next.id === "(string)") {
        p = peek(0);
        if (p.id === "(endline)") {
          i = 1;
          do {
            pn = peek(i);
            i = i + 1;
          } while (pn.id === "(endline)");

          if (pn.id !== ";") {
            if (pn.id !== "(string)" && pn.id !== "(number)" &&
              pn.id !== "(regexp)" && pn.identifier !== true &&
              pn.id !== "}") {
              break;
            }
            warning("W033", state.tokens.next);
          } else {
            p = pn;
          }
        } else if (p.id === "}") {
          // Directive with no other statements, warn about missing semicolon
          warning("W033", p);
        } else if (p.id !== ";") {
          break;
        }

        advance();
        if (state.directive[state.tokens.curr.value]) {
          warning("W034", state.tokens.curr, state.tokens.curr.value);
        }

        if (state.tokens.curr.value === "use strict") {
          if (!state.option["(explicitNewcap)"])
            state.option.newcap = true;
          state.option.undef = true;
        }

        // there's no directive negation, so always set to true
        state.directive[state.tokens.curr.value] = true;

        if (p.id === ";") {
          advance(";");
        }
        continue;
      }
      break;
    }
  }
809204
def build_source_list_directive(directive)
      source_list = @config.directive_value(directive)

      if source_list != OPT_OUT && source_list && source_list.any?
        normalized_source_list = minify_source_list(directive, source_list)
        [symbol_to_hyphen_case(directive), normalized_source_list].join(" ")
      end
    end
1130023
def do_classes

      # look for class renames like
      #   %rename(Solvable) _Solvable;
      #   typedef struct _Solvable {} XSolvable; /* expose XSolvable as 'Solvable' */

      extends = Hash.new
      @body.scan(/^%rename\s*\(([^\"\)]+)\)\s+([_\w]+);/) do |class_name, struct_name|
#	puts "rename #{class_name} -> #{struct_name}"
	extend_name = struct_name.to_s
	@body.scan(/typedef\s+struct\s+#{struct_name}\s*\{[^}]*\}\s*(\w+);/) do |ename|
	  extend_name = ename.to_s
	end
	
#	puts "extend #{extend_name}, class #{class_name}, struct #{struct_name}"
	# find the corresponding '%extend' directive
	@body.scan(/^%extend\s+(#{extend_name}|#{struct_name})\s*\{(.*)\}/mx) do |name,content|
	  # now check if we have multiple %extend, the regexp above is greedy and will match all of them
	  while content.to_s =~ /^%extend/
	    content = $` # discard %extend and everything behind
	  end
	  extends[name] = true
	  cn = class_name.to_s
	  cn.capitalize! unless cn[0,1] =~ /[A-Z_]/
	  swig_class = handle_class_module("class", cn, :parent => "rb_cObject", :content => content.to_s, :extend_name => name)
	end
      end
      @body.scan(/^%extend\s*(\w+)\s*\{(.*)\}/mx) do |class_name,content|
	cn = class_name.to_s
	unless extends[cn]
#	  puts "Class #{cn}"
	  cn.capitalize! unless cn[0,1] =~ /[A-Z_]/
	  swig_class = handle_class_module("class", cn, :parent => "rb_cObject", :content => content)
	  extends[cn] = true
	end
      end
    end
739087
def method_missing m, *args, &block
      if method_name_is_tag_name? m
        return assign_tag(m, args, &block)
      elsif method_name_is_tag_adder_method? m 
        return extend_tag_list(m, args, &block)
      elsif method_name_is_tag_list_method? m
        return child_tags[m[0..-6].to_sym] ||= []
      elsif method_name_is_attr_accessor_method? m
        return assign_attribute(m[0..-6].to_sym, args, &block)
      end
      super(m, *args, &block)
    end
729523
def explain_the_role description
      name = ConstName.from description
      begin
        find_directives_for name
      rescue NameError
        raise "I can't find a role called '#{ name }'. Have you created it?\ne.g.\n  module #{ name }\n  end\n\n"
      end
    end
716898
function checkDirectives(node) {
            const directives = astUtils.getDirectivePrologue(node);

            if (!directives.length) {
                return;
            }

            const firstDirective = directives[0];
            const leadingComments = sourceCode.getCommentsBefore(firstDirective);

            /*
             * Only check before the first directive if it is preceded by a comment or if it is at the top of
             * the file and expectLineBefore is set to "never". This is to not force a newline at the top of
             * the file if there are no comments as well as for compatibility with padded-blocks.
             */
            if (leadingComments.length) {
                if (expectLineBefore === "always" && !hasNewlineBefore(firstDirective)) {
                    reportError(firstDirective, "before", true);
                }

                if (expectLineBefore === "never" && hasNewlineBefore(firstDirective)) {
                    reportError(firstDirective, "before", false);
                }
            } else if (
                node.type === "Program" &&
                expectLineBefore === "never" &&
                !leadingComments.length &&
                hasNewlineBefore(firstDirective)
            ) {
                reportError(firstDirective, "before", false);
            }

            const lastDirective = directives[directives.length - 1];
            const statements = node.type === "Program" ? node.body : node.body.body;

            /*
             * Do not check after the last directive if the body only
             * contains a directive prologue and isn't followed by a comment to ensure
             * this rule behaves well with padded-blocks.
             */
            if (lastDirective === statements[statements.length - 1] && !lastDirective.trailingComments) {
                return;
            }

            if (expectLineAfter === "always" && !hasNewlineAfter(lastDirective)) {
                reportError(lastDirective, "after", true);
            }

            if (expectLineAfter === "never" && hasNewlineAfter(lastDirective)) {
                reportError(lastDirective, "after", false);
            }
        }