From ef92da3768d8746dbfe72e77232f78b879fc811d Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Wed, 12 Apr 2017 19:12:01 +0200 Subject: [PATCH] Docs: Additional notes on ext/descriptor [ci skip] --- ext/descriptor/README.md | 4 ++-- ext/descriptor/index.d.ts | 2 +- ext/descriptor/index.js | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/descriptor/README.md b/ext/descriptor/README.md index 95df5a885..dff1bef32 100644 --- a/ext/descriptor/README.md +++ b/ext/descriptor/README.md @@ -10,7 +10,7 @@ Usage var protobuf = require("protobufjs"), descriptor = require("protobufjs/ext/descriptor"); -var descriptor = ...; // either a FieldDescriptorSet buffer or JSON object +var descriptor = ...; // either a FieldDescriptorSet buffer, a FieldDescriptorSet message instance or a corresponding valid JSON object var root = protobuf.Root.fromDescriptor(descriptor); var rootDescriptor = root.toDescriptor("proto3"); ``` @@ -18,4 +18,4 @@ var rootDescriptor = root.toDescriptor("proto3"); API --- -The extension adds `.fromDescriptor(descriptor[, syntax])` and `#toDescriptor([syntax])` methods to reflection objects and exports the internally used `Root` instance that contains the types present in descriptor.proto. +The extension adds `.fromDescriptor(descriptor[, syntax])` and `#toDescriptor([syntax])` methods to reflection objects and exports the `.google.protobuf` namespace of the internally used `Root` instance containing the types present in descriptor.proto. diff --git a/ext/descriptor/index.d.ts b/ext/descriptor/index.d.ts index 849ea236d..7f3c43f55 100644 --- a/ext/descriptor/index.d.ts +++ b/ext/descriptor/index.d.ts @@ -1,6 +1,6 @@ import * as $protobuf from "../.."; -declare const descriptor: $protobuf.Root; +declare const descriptor: $protobuf.Namespace; interface IFileDescriptorSet { file: IFileDescriptorProto[]; diff --git a/ext/descriptor/index.js b/ext/descriptor/index.js index 9959b40e0..f07243c50 100644 --- a/ext/descriptor/index.js +++ b/ext/descriptor/index.js @@ -4,13 +4,15 @@ var $protobuf = require(".."); /** * Descriptor extension (ext/descriptor). + * Exports the `.google.protobuf` namespace of the internally used {@link Root} instance containing the types present in descriptor.proto. * @type {Root} - * @tstype $protobuf.Root + * @tstype $protobuf.Namespace * @const + * @see https://github.com/dcodeIO/protobuf.js/tree/master/ext/descriptor */ var descriptor = module.exports = $protobuf.Root.fromJSON(require("../google/protobuf/descriptor.json")).lookup(".google.protobuf"); -var google = descriptor, +var google = descriptor, // aliased used where `descriptor` is a local var Root = $protobuf.Root, Enum = $protobuf.Enum, Type = $protobuf.Type, @@ -44,7 +46,7 @@ var google = descriptor, /** * Creates a root from a descriptor set. - * @param {Properties|Reader|Uint8Array} descriptor Descriptor + * @param {IFileDescriptorSet|Reader|Uint8Array} descriptor Descriptor * @returns {Root} Root instance * @see Part of the {@link descriptor} extension (ext/descriptor) */ @@ -144,7 +146,7 @@ var unnamedMessageIndex = 0; /** * Creates a type from a descriptor. - * @param {Properties|Reader|Uint8Array} descriptor Descriptor + * @param {IDescriptorProto|Reader|Uint8Array} descriptor Descriptor * @param {string} [syntax="proto2"] Syntax * @returns {Type} Type instance * @see Part of the {@link descriptor} extension (ext/descriptor) @@ -520,7 +522,7 @@ var unnamedServiceIndex = 0; /** * Creates a service from a descriptor. - * @param {Properties|Reader|Uint8Array} descriptor Descriptor + * @param {IServiceDescriptorProto|Reader|Uint8Array} descriptor Descriptor * @returns {Service} Service instance * @see Part of the {@link descriptor} extension (ext/descriptor) */