def __init__(self): # Load as YAML, emit as JSON and then parse as proto to provide type # checking. protodoc_manifest_untyped = utils.from_yaml( r.Rlocation('envoy/docs/protodoc_manifest.yaml')) self.protodoc_manifest = manifest_pb2.Manifest() json_format.Parse(json.dumps(protodoc_manifest_untyped), self.protodoc_manifest)
def __init__(self): r = runfiles.Create() with open(r.Rlocation('envoy/docs/protodoc_manifest.yaml'), 'r') as f: # Load as YAML, emit as JSON and then parse as proto to provide type # checking. protodoc_manifest_untyped = yaml.safe_load(f.read()) self.protodoc_manifest = manifest_pb2.Manifest() json_format.Parse(json.dumps(protodoc_manifest_untyped), self.protodoc_manifest)
def main(output): # Load as YAML, emit as JSON and then parse as proto to provide type # checking. manifest = json_format.Parse(json.dumps(protodoc_manifest_untyped), manifest_pb2.Manifest()) result = {} for field_name in manifest.fields: field = manifest.fields[field_name] example = json_format.MessageToDict(field.edge_config.example) parts = field_name.split(".") name = ".".join(parts[:-1]) part = parts[-1] validate_fragment.validate_fragment(name, {part: example}) result[field_name] = dict(note=field.edge_config.note, example=example) pathlib.Path(output).write_text(json.dumps(result))
def __init__(self): # Load as YAML, emit as JSON and then parse as proto to provide type # checking. self.protodoc_manifest = manifest_pb2.Manifest() json_format.Parse(json.dumps(protodoc_manifest_untyped), self.protodoc_manifest)