Skip to content

Commit 61e74cf

Browse files
committed
add setting to disable generation of eloquent doc blocks
1 parent 0f462ab commit 61e74cf

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@
113113
"default": true,
114114
"description": "Show popups for errors."
115115
},
116+
"Laravel.eloquent.generateDocBlocks": {
117+
"type": "boolean",
118+
"default": true,
119+
"description": "Automatically generate Eloquent doc blocks for models as IDE helpers."
120+
},
116121
"Laravel.blade.autoSpaceTags": {
117122
"type": "boolean",
118123
"default": true,

src/support/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ type ConfigKey =
1010
| "tests.ssh.enabled"
1111
| "tests.suiteSuffix"
1212
| "showErrorPopups"
13-
| "blade.autoSpaceTags";
13+
| "blade.autoSpaceTags"
14+
| "eloquent.generateDocBlocks";
1415

1516
export const config = <T>(key: ConfigKey, fallback: T): T =>
1617
vscode.workspace.getConfiguration("Laravel").get<T>(key, fallback);

src/support/docblocks.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "fs";
22
import { Eloquent } from "..";
3+
import { config } from "./config";
34
import { internalVendorPath } from "./project";
45
import { indent } from "./util";
56

@@ -16,7 +17,7 @@ export const writeEloquentDocBlocks = (
1617
models: Eloquent.Models,
1718
builderMethods: Eloquent.BuilderMethod[],
1819
) => {
19-
if (!models) {
20+
if (!models || !config("eloquent.generateDocBlocks", true)) {
2021
return;
2122
}
2223

@@ -113,7 +114,9 @@ const getBlocks = (
113114
.concat(
114115
[...model.scopes, "newModelQuery", "newQuery", "query"].map(
115116
(method) => {
116-
return `@method static ${modelBuilderType(className)} ${method}()`;
117+
return `@method static ${modelBuilderType(
118+
className,
119+
)} ${method}()`;
117120
},
118121
),
119122
)
@@ -205,7 +208,9 @@ const getAttributeBlocks = (
205208

206209
if (!["accessor", "attribute"].includes(attr.cast || "")) {
207210
blocks.push(
208-
`@method static ${modelBuilderType(className)} where${attr.title_case}($value)`,
211+
`@method static ${modelBuilderType(className)} where${
212+
attr.title_case
213+
}($value)`,
209214
);
210215
}
211216

0 commit comments

Comments
 (0)