/* a helper to build option specification object from string spec

@param $specString string
@param $description string
@param $key
770195
function add( $specString, $description , $key = null ) 
    {
        $spec = $this->specs->add($specString,$description,$key);
        return $spec;
    }
91466
function specCharsToASCII($charset, $string) {
		if ($charset == 'utf-8') {
			$string = $this->utf8_char_mapping($string, 'ascii');
		} elseif (isset($this->eucBasedSets[$charset])) {
			$string = $this->euc_char_mapping($string, $charset, 'ascii');
		} else {
				// treat everything else as single-byte encoding
			$string = $this->sb_char_mapping($string, $charset, 'ascii');
		}

		return $string;
	}
1151114
private SpecTopic parseSpecTopicMetaData(final ParserData parserData, final String value, final String key,
            final int lineNumber) throws ParsingException {
        final String fixedValue = value.trim().replaceAll("(?i)^" + key + "\\s*", "");
        if (fixedValue.trim().startsWith("[") && fixedValue.trim().endsWith("]")) {
            final String topicString = key + " " + fixedValue.trim();
            return parseTopic(parserData, topicString, lineNumber);
        } else {
            if (fixedValue.trim().startsWith("[")) {
                throw new ParsingException(format(ProcessorConstants.ERROR_NO_ENDING_BRACKET_MSG, lineNumber, ']'));
            } else if (fixedValue.trim().endsWith("]")) {
                throw new ParsingException(format(ProcessorConstants.ERROR_NO_OPENING_BRACKET_MSG, lineNumber, '['));
            } else {
                throw new ParsingException(format(ProcessorConstants.ERROR_NO_BRACKET_MSG, lineNumber, '[', ']'));
            }
        }
    }
387678
function(results, options) {
        var uri = options.uri || 'http://' + window.location.host + '/results'
        JSpec.post(uri, {
          stats: JSpec.stats,
          options: options,
          results: map(results.allSuites, function(suite) {
            if (suite.hasSpecs())
              return {
                description: suite.description,
                specs: map(suite.specs, function(spec) {
                  return {
                    description: spec.description,
                    message: !spec.passed() ? spec.failure().message : null,
                    status: spec.requiresImplementation() ? 'pending' :
                              spec.passed() ? 'pass' :
                                'fail',
                    assertions: map(spec.assertions, function(assertion){
                      return {
                        passed: assertion.passed  
                      }
                    })
                  }
                })
              }
          })
        })
  			if ('close' in main) main.close()
      }
833547
def specs_to_string(specs):
    # type: (List[Union[STRING_TYPE, Specifier]]) -> AnyStr
    

    if specs:
        if isinstance(specs, six.string_types):
            return specs
        try:
            extras = ",".join(["".join(spec) for spec in specs])
        except TypeError:
            extras = ",".join(["".join(spec._spec) for spec in specs])  # type: ignore
        return extras
    return ""
271653
private static final List<Element> buildDescription(String description) {
		
		// Assertions.
		if (description == null) {
			String msg = "Argument 'description' cannot be null.";
			throw new IllegalArgumentException(msg);
		}
		
		List<Element> rslt = new LinkedList<Element>();
		Element e = fac.createElement("p");
		e.setText(description);
		rslt.add(e);
		return rslt;

	}
734347
private static String[] determineDescription(CliDeclaredOptionSpec cliCommand, boolean fullDescription, int maxTextWidth) {
        final List<String> descriptions = formatOptionDescription(cliCommand, maxTextWidth);
        if (!fullDescription && descriptions.size() > 1) {
            return new String[] {getFirst(descriptions) + " (...more)"};
        } else {
            return descriptions.toArray(new String[]{});
        }
    }
594801
protected Term buildIdTerm(String spaceId, String key) {
        return new Term(FIELD_ID, spaceId.trim() + ":" + key.trim());
    }
144449
function GENERATE_ENUM(name, spec, parent) {
  return GENERATE_DOC(spec.description + '\n'
    + '@property ' + name + '\n'
    + '@type Enum ' + spec.type + '\n'
    + '@for ' + (parent ? parent : 'common') + '\n');
}
1013789
public static function parse($optionDescription) {
        $short    = null;
        $long     = null;
        $argcount = 0;
        $value    = false;

        $exp = explode('  ', trim($optionDescription), 2);
        $options = $exp[0];
        $description = isset($exp[1]) ? $exp[1] : '';

        $options = str_replace(',', ' ', str_replace('=', ' ', $options));
        foreach (preg_split('/\s+/', $options) as $s) {
            if (strpos($s, '--')===0) {
                $long = $s;
            }
            elseif ($s && $s[0] == '-') {
                $short = $s;
            }
            else {
                $argcount = 1;
            }
        }

        if ($argcount) {
            $value = null;
            if (preg_match('@\[default: (.*)\]@i', $description, $match))
                $value = $match[1];
        }
        return new static($short, $long, $argcount, $value);
    }
695277
public static TransposePathElement parse( String key ) {

        if ( key == null || key.length() < 2 ) {
            throw new SpecException( "'Transpose Input' key '@', can not be null or of length 1.  Offending key : " + key );
        }
        if ( '@' != key.charAt( 0 ) ) {
            throw new SpecException( "'Transpose Input' key must start with an '@'.  Offending key : " + key );
        }

        // Strip off the leading '@' as we don't need it anymore.
        String meat = key.substring( 1 );

        if ( meat.contains( "@" ) ) {
            throw new SpecException( "@ pathElement can not contain a nested @. Was: " + meat );
        }
        if ( meat.contains( "*" ) || meat.contains( "[]" ) ) {
            throw new SpecException( "'Transpose Input' can not contain expansion wildcards (* and []).  Offending key : " + key );
        }

        // Check to see if the key is wrapped by parens
        if ( meat.startsWith( "(" ) ) {
            if ( meat.endsWith( ")" ) ) {
                meat = meat.substring( 1, meat.length() - 1 );
            }
            else {
                throw new SpecException( "@ path element that starts with '(' must have a matching ')'.  Offending key : " + key );
            }
        }

        return innerParse( key, meat );
    }
1026203
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1869")
  public final <T> S withOption(CallOptions.Key<T> key, T value) {
    return build(channel, callOptions.withOption(key, value));
  }
918165
@Override
	protected StringBuilder endSection( String sectionName, StringBuilder sb ) {

		StringBuilder result = sb;
		if( this.options.containsKey( DocConstants.OPTION_HTML_EXPLODED )) {
			this.sectionNameToContent.put( sectionName, sb );
			result = new StringBuilder();

		} else {
			result.append( "<p class=\"separator\"> &nbsp; </p>\n" );
		}

		return result;
	}
271274
function(description, body) {
          var spec = new JSpec.Spec(description, body)
          this.specs.push(spec)
          JSpec.stats.specs++ // TODO: abstract
          spec.suite = this
        }
46915
public static PJsonObject parseSpec(final String spec) {
        final JSONObject jsonSpec;
        try {
            jsonSpec = new JSONObject(spec);
        } catch (JSONException e) {
            throw new RuntimeException("Cannot parse the spec file: " + spec, e);
        }
        return new PJsonObject(jsonSpec, "spec");
    }
1320301
protected function buildOptionLineData($option_line_spec) {
    $data = array();

    $switch_text = '';
    if (strlen($option_line_spec['short'])) {
      $switch_text .= "-".$option_line_spec['short'];
    }
    if (strlen($option_line_spec['long'])) {
      $switch_text .= ($switch_text ? ", " : "")."--".$option_line_spec['long'];
    }

    $data = array(
      'switch_text' => $switch_text.(strlen($option_line_spec['value_name']) ? ' <'.$option_line_spec['value_name'].'>' : ''),
      'spec'        => $option_line_spec,
    );

    return $data;
  }
652423
@NonNull
  public static Caffeine<Object, Object> from(String spec) {
    return from(CaffeineSpec.parse(spec));
  }