-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add json export to docs generator (#4746)
- Loading branch information
1 parent
e095e93
commit 2e00b8f
Showing
7 changed files
with
174 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Crystal::Doc | ||
record Main, body : String, program : Type, repository_name : String do | ||
def to_s(io : IO) | ||
to_json(io) | ||
end | ||
|
||
def to_json(builder : JSON::Builder) | ||
builder.object do | ||
builder.field "repository_name", repository_name | ||
builder.field "body", body | ||
builder.field "program", program | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class Crystal::Arg | ||
def to_json(builder : JSON::Builder) | ||
builder.object do | ||
builder.field "name", name | ||
builder.field "doc", doc | ||
builder.field "default_value", default_value.to_s | ||
builder.field "external_name", external_name.to_s | ||
builder.field "restriction", restriction.to_s | ||
end | ||
end | ||
end | ||
|
||
class Crystal::Def | ||
def to_json(builder : JSON::Builder) | ||
builder.object do | ||
builder.field "name", name | ||
builder.field "args", args | ||
builder.field "double_splat", double_splat | ||
builder.field "splat_index", splat_index | ||
builder.field "yields", yields | ||
builder.field "block_arg", block_arg | ||
builder.field "return_type", return_type.to_s | ||
builder.field "visibility", visibility.to_s | ||
builder.field "body", body.to_s | ||
end | ||
end | ||
end | ||
|
||
class Crystal::Macro | ||
def to_json(builder : JSON::Builder) | ||
builder.object do | ||
builder.field "name", name | ||
builder.field "args", args | ||
builder.field "double_splat", double_splat | ||
builder.field "splat_index", splat_index | ||
builder.field "block_arg", block_arg | ||
builder.field "visibility", visibility.to_s | ||
builder.field "body", body.to_s | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters