AST: Factor shebangs out of non-code metadata and into Program (#4557)

* AST: Factor shebangs out of non-code metadata and into Progam

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Empty commit to try to unstick CI

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2024-11-26 16:39:57 +13:00
committed by GitHub
parent 30bc85add8
commit 5424252dac
13 changed files with 386 additions and 254 deletions

View File

@ -96310,6 +96310,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -97944,25 +97952,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -98173,6 +98162,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [
@ -100282,6 +100293,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -101916,25 +101935,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -102145,6 +102145,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [
@ -104258,6 +104280,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -105892,25 +105922,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -106121,6 +106132,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [
@ -137489,6 +137522,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -139123,25 +139164,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -139352,6 +139374,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [
@ -142077,6 +142121,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -143711,25 +143763,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -143940,6 +143973,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [
@ -146666,6 +146721,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -148300,25 +148363,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -148529,6 +148573,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [
@ -150653,6 +150719,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -152287,25 +152361,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -152516,6 +152571,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [
@ -155241,6 +155318,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -156875,25 +156960,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -157104,6 +157170,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [
@ -159213,6 +159301,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -160847,25 +160943,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -161076,6 +161153,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [
@ -163802,6 +163901,14 @@
"nonCodeMeta": {
"$ref": "#/components/schemas/NonCodeMeta"
},
"shebang": {
"allOf": [
{
"$ref": "#/components/schemas/Shebang"
}
],
"nullable": true
},
"digest": {
"type": "array",
"items": {
@ -165436,25 +165543,6 @@
},
"NonCodeValue": {
"oneOf": [
{
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"enum": [
"shebang"
]
},
"value": {
"type": "string"
}
}
},
{
"description": "An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.",
"type": "object",
@ -165665,6 +165753,28 @@
}
]
},
"Shebang": {
"description": "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```",
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"start": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"end": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
}
},
"ProgramMemory": {
"type": "object",
"required": [

View File

@ -11,23 +11,6 @@ layout: manual
**This schema accepts exactly one of the following:**
A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```
**Type:** `object`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: `shebang`| | No |
| `value` |`string`| | No |
----
An inline comment. Here are examples: `1 + 1 // This is an inline comment`. `1 + 1 /* Here's another */`.
**Type:** `object`

View File

@ -18,6 +18,7 @@ A KCL program top level, or function body.
|----------|------|-------------|----------|
| `body` |`[` [`BodyItem`](/docs/kcl/types/BodyItem) `]`| | No |
| `nonCodeMeta` |[`NonCodeMeta`](/docs/kcl/types/NonCodeMeta)| A KCL program top level, or function body. | No |
| `shebang` |[`Shebang`](/docs/kcl/types/Shebang)| | No |
| `digest` |`[, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`, `integer`]`| | No |
| `start` |`integer`| | No |
| `end` |`integer`| | No |

23
docs/kcl/types/Shebang.md Normal file
View File

@ -0,0 +1,23 @@
---
title: "Shebang"
excerpt: "A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```"
layout: manual
---
A shebang. This is a special type of comment that is at the top of the file. It looks like this: ```python,no_run #!/usr/bin/env python ```
**Type:** `object`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `content` |`string`| | No |
| `start` |`integer`| | No |
| `end` |`integer`| | No |