tree: cf4d324784d1760f6a1f78eee7f7efc722e27636 [path history] [tgz]
  4. aliases.go
  5. bits.go
  6. consts.go
  7. elementslice.go
  8. elementslice_test.go
  9. elementstr.go
  10. enums.go
  11. library.go
  12. properties.go
  13. protocol.go
  14. summary.go
  15. summary_test.go
  16. wraparoundtype.go
  17. 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