tree: 567c476f72ea2d06d341def408ad0b419941150f [path history] [tgz]
  1. aliases.go
  2. bits.go
  4. consts.go
  5. elementslice.go
  6. elementslice_test.go
  7. elementstr.go
  8. enums.go
  9. library.go
  10. OWNERS
  11. properties.go
  12. protocol.go
  14. summary.go
  15. summary_test.go
  16. symboltable.go
  17. symboltable_test.go
  18. wraparoundtype.go
  19. wraparoundtype_test.go


The summarize library is used to produce an API summary of a FIDL library. The information is extracted from the FIDL intermediate representation (IR) abstract syntax tree.


Here is an example that includes the library into another go library, which is then rolled into a binary.

go_library("gopkg") {
  name = "main"
  sources = [ "main.go" ]
  deps = [

go_binary("fidl_api_summarize") {
  gopackage = "main"
  deps = [ ":gopkg" ]

Then, you can refer to the functionality as:

import (
  // ...

func main() {
    // This is an incomplete code fragment: you will need to initialize in and w
    // properly.
    var (
      // in needs to be properly initialized.  The reader must yield the FIDL IR
      // you want to analyze encoded as JSON text.
      in io.Reader
      // w is where the API summary output is to be written.  Needs to be properly
      // initialized.
      w io.Writer
      // root is the root of the FIDL IR AST.
      root fidlgen.Root
	root, err := fidlgen.DecodeJSONIr(in)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Could not parse FIDL IR from: %v: %v", *in, err)
	if err := summarize.Write(root, w); err != nil {
		fmt.Fprintf(os.Stderr, "While summarizing %v into %v: %v", *in, *out, err)

API usage hints

The two main functions offered by the library are summarize.Write, which will write out an API summary in text format to a writer, and summarize.Elements which yields a sequence of API elements for further analysis.


fx build tools/fidl/fidl_api_summarize



  • Make sure you have --with=//tools/fidl:tests in your fx set

Run the tests like so:

fx test tools/fidl/lib/summarize