Skip to content

Commit

Permalink
docs: dont rely on code blocks to change language in code_selector
Browse files Browse the repository at this point in the history
  • Loading branch information
gak committed Aug 28, 2024
1 parent bf5adf5 commit 0d75bb1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
8 changes: 0 additions & 8 deletions cmd/ftl-gen-lsp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,6 @@ func stripNonGoDocs(content string) string {
continue
}

// Similar, look at the code block
if strings.HasPrefix(line, "```") {
newLang := strings.TrimPrefix(line, "```")
if newLang != "" {
currentLang = newLang
}
}

// If we're in a Go block or unspecified, collect the line.
if currentLang == "go" || currentLang == "" {
collected = append(collected, line)
Expand Down
4 changes: 4 additions & 0 deletions docs/content/docs/reference/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ top = false

Some aspects of FTL rely on a runtime which must be imported with:

<!-- go -->

```go
import "github.com/TBD54566975/ftl/go-runtime/ftl"
```

<!-- kotlin -->

```kotlin
// Declare a verb you want to use:
import xyz.block.ftl.Verb
Expand Down
22 changes: 12 additions & 10 deletions docs/content/docs/reference/verbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,11 @@ top = false
<!-- go -->
To declare a Verb, write a normal Go function with the following signature, annotated with the Go [comment directive](https://tip.golang.org/doc/comment#syntax) `//ftl:verb`:

<!-- kotlin -->
To declare a Verb, write a normal Kotlin function with the following signature, annotated with the Kotlin [annotation](https://kotlinlang.org/docs/annotations.html) `@Verb`:

```go
//ftl:verb
func F(context.Context, In) (Out, error) { }
```

```kotlin
@Verb
fun F(Context, In): Out { }
```

eg.

```go
Expand All @@ -46,6 +38,16 @@ func Echo(ctx context.Context, in EchoRequest) (EchoResponse, error) {
}
```

<!-- kotlin -->
To declare a Verb, write a normal Kotlin function with the following signature, annotated with the Kotlin [annotation](https://kotlinlang.org/docs/annotations.html) `@Verb`:

```kotlin
@Verb
fun F(Context, In): Out { }
```

eg.

```kotlin
data class EchoRequest
data class EchoResponse
Expand All @@ -56,10 +58,10 @@ fun echo(ctx: Context, request: EchoRequest): EchoResponse {
}
```

By default verbs are only [visible](../visibility) to other verbs in the same module.

{% end %}

By default verbs are only [visible](../visibility) to other verbs in the same module.

## Calling Verbs

{% code_selector() %}
Expand Down
6 changes: 0 additions & 6 deletions docs/static/js/code-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ function injectTabs(codeSelector) {
currentLang = lang;
toAdd = { lang, element };
}
} else if (element.tagName === "PRE") {
// pre with data-lang attribute
const lang = element.getAttribute("data-lang");
// code blocks reset the currentLang.
currentLang = null;
toAdd = { lang, element };
} else if (currentLang) {
// if we are in a currentLang, then add the element to it.
toAdd = { lang: currentLang, element };
Expand Down
4 changes: 2 additions & 2 deletions internal/lsp/hoveritems.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d75bb1

Please sign in to comment.