Skip to content

Commit

Permalink
add --no-examples option (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored Nov 9, 2023
1 parent 9ff7548 commit b799243
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-crabs-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/docgen": patch
---

add `--no-examples` option
1 change: 1 addition & 0 deletions docs/modules/Process.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Represents a handle to the currently executing process.
export interface Process {
readonly cwd: Effect.Effect<never, never, string>
readonly platform: Effect.Effect<never, never, string>
readonly argv: Effect.Effect<never, never, Array<string>>
}
```

Expand Down
10 changes: 8 additions & 2 deletions src/Core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,19 @@ const writeMarkdown = (files: ReadonlyArray<FileSystem.File>) =>
return yield* _(writeFilesToOutDir(files))
})

const NO_EXAMPLES_OPTION = "--no-examples"

const program = Effect.gen(function*(_) {
yield* _(Effect.logInfo("Reading modules..."))
const sourceFiles = yield* _(readSourceFiles)
yield* _(Effect.logInfo("Parsing modules..."))
const modules = yield* _(parseModules(sourceFiles))
yield* _(Effect.logInfo("Typechecking examples..."))
yield* _(typeCheckAndRunExamples(modules))
const process = yield* _(Process.Process)
const argv = yield* _(process.argv)
if (!argv.slice(2).some((arg) => arg === NO_EXAMPLES_OPTION)) {
yield* _(Effect.logInfo("Typechecking examples..."))
yield* _(typeCheckAndRunExamples(modules))
}
yield* _(Effect.logInfo("Creating markdown files..."))
const outputFiles = yield* _(getMarkdown(modules))
yield* _(Effect.logInfo("Writing markdown files..."))
Expand Down
4 changes: 3 additions & 1 deletion src/Process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Context, Effect, Layer } from "effect"
export interface Process {
readonly cwd: Effect.Effect<never, never, string>
readonly platform: Effect.Effect<never, never, string>
readonly argv: Effect.Effect<never, never, Array<string>>
}

/**
Expand All @@ -29,6 +30,7 @@ export const ProcessLive = Layer.succeed(
Process,
Process.of({
cwd: Effect.sync(() => process.cwd()),
platform: Effect.sync(() => process.platform)
platform: Effect.sync(() => process.platform),
argv: Effect.sync(() => process.argv)
})
)

0 comments on commit b799243

Please sign in to comment.