From 87b359eb5242b1862d627f8a9a29d3602bb0d3b2 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Tue, 25 Jun 2024 12:54:22 -0400 Subject: [PATCH 1/2] [Go] use a Makefile to generate doc-go files --- docs-go/Makefile | 10 ++++++++++ docs-go/{flows => flows.src} | 0 docs-go/{models => models.src} | 0 go/internal/cmd/weave/weave.go | 1 + 4 files changed, 11 insertions(+) create mode 100644 docs-go/Makefile rename docs-go/{flows => flows.src} (100%) rename docs-go/{models => models.src} (100%) diff --git a/docs-go/Makefile b/docs-go/Makefile new file mode 100644 index 0000000000..ac1ffd0125 --- /dev/null +++ b/docs-go/Makefile @@ -0,0 +1,10 @@ +WEAVE=$(HOME)/go/bin/weave + +all: $(WEAVE) flows.md models.md + +$(WEAVE): ../go/internal/cmd/weave/*.go + go -C ../go install ./internal/cmd/weave + +%.md: %.src + $(WEAVE) $< > $@ + diff --git a/docs-go/flows b/docs-go/flows.src similarity index 100% rename from docs-go/flows rename to docs-go/flows.src diff --git a/docs-go/models b/docs-go/models.src similarity index 100% rename from docs-go/models rename to docs-go/models.src diff --git a/go/internal/cmd/weave/weave.go b/go/internal/cmd/weave/weave.go index 71a1cc72be..9f69560e23 100644 --- a/go/internal/cmd/weave/weave.go +++ b/go/internal/cmd/weave/weave.go @@ -219,6 +219,7 @@ func cleanListing(text, indent string) string { return strings.Join(lines, "\n") } +// leadingTabs counts the number of tabs that start s. func leadingTabs(s string) int { var i int for i = 0; i < len(s); i++ { From f4cd3248246459d17203a491734dd10272420089 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Tue, 25 Jun 2024 17:35:58 -0400 Subject: [PATCH 2/2] add go:generate for docs --- go/internal/doc-snippets/doc.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 go/internal/doc-snippets/doc.go diff --git a/go/internal/doc-snippets/doc.go b/go/internal/doc-snippets/doc.go new file mode 100644 index 0000000000..9e9f9d1b90 --- /dev/null +++ b/go/internal/doc-snippets/doc.go @@ -0,0 +1,19 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package snippets contains snippets that are incorporated into +// documentation (see the docs-go directory under the repo root). +package snippets + +//go:generate make -C ../../../docs-go