Don't truncate extrude arg docs (#6854)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -26,7 +26,7 @@ You can provide more than one sketch to extrude, and they will all be extruded i
|
|||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketches` | [`[Sketch]`](/docs/kcl-std/types/std-types-Sketch) | Which sketch or sketches should be extruded | Yes |
|
| `sketches` | [`[Sketch]`](/docs/kcl-std/types/std-types-Sketch) | Which sketch or sketches should be extruded | Yes |
|
||||||
| `length` | [`number`](/docs/kcl-std/types/std-types-number) | How far to extrude the given sketches | Yes |
|
| `length` | [`number`](/docs/kcl-std/types/std-types-number) | How far to extrude the given sketches | Yes |
|
||||||
| `symmetric` | [`bool`](/docs/kcl-std/types/std-types-bool) | If true, the extrusion will happen symmetrically around the sketch. Otherwise, the | No |
|
| `symmetric` | [`bool`](/docs/kcl-std/types/std-types-bool) | If true, the extrusion will happen symmetrically around the sketch. Otherwise, the extrusion will happen on only one side of the sketch. | No |
|
||||||
| `bidirectionalLength` | [`number`](/docs/kcl-std/types/std-types-number) | If specified, will also extrude in the opposite direction to 'distance' to the specified distance. If 'symmetric' is true, this value is ignored. | No |
|
| `bidirectionalLength` | [`number`](/docs/kcl-std/types/std-types-number) | If specified, will also extrude in the opposite direction to 'distance' to the specified distance. If 'symmetric' is true, this value is ignored. | No |
|
||||||
| `tagStart` | [`TagDeclarator`](/docs/kcl-lang/types#TagDeclarator) | A named tag for the face at the start of the extrusion, i.e. the original sketch | No |
|
| `tagStart` | [`TagDeclarator`](/docs/kcl-lang/types#TagDeclarator) | A named tag for the face at the start of the extrusion, i.e. the original sketch | No |
|
||||||
| `tagEnd` | [`TagDeclarator`](/docs/kcl-lang/types#TagDeclarator) | A named tag for the face at the end of the extrusion, i.e. the new face created by extruding the original sketch | No |
|
| `tagEnd` | [`TagDeclarator`](/docs/kcl-lang/types#TagDeclarator) | A named tag for the face at the end of the extrusion, i.e. the new face created by extruding the original sketch | No |
|
||||||
|
@ -78747,7 +78747,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": false,
|
"required": false,
|
||||||
"description": "If true, the extrusion will happen symmetrically around the sketch. Otherwise, the\n extrusion will happen on only one side of the sketch.",
|
"description": "If true, the extrusion will happen symmetrically around the sketch. Otherwise, the extrusion will happen on only one side of the sketch.",
|
||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -380,6 +380,21 @@ fn generate_function_from_kcl(
|
|||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(index, example)| generate_example(index, &example.0, &example.1, &example_name))
|
.filter_map(|(index, example)| generate_example(index, &example.0, &example.1, &example_name))
|
||||||
.collect();
|
.collect();
|
||||||
|
let args = function.args.iter().map(|arg| {
|
||||||
|
let docs = arg.docs.clone();
|
||||||
|
if let Some(docs) = &docs {
|
||||||
|
// We deliberately truncate to one line in the template so that if we are using the docs
|
||||||
|
// from the type, then we only take the summary. However, if there's a newline in the
|
||||||
|
// arg docs, then they would get truncated unintentionally.
|
||||||
|
assert!(!docs.contains('\n'), "Arg docs will get truncated");
|
||||||
|
};
|
||||||
|
json!({
|
||||||
|
"name": arg.name,
|
||||||
|
"type_": arg.ty,
|
||||||
|
"description": docs.or_else(|| arg.ty.as_ref().and_then(|t| super::docs_for_type(t, kcl_std))).unwrap_or_default(),
|
||||||
|
"required": arg.kind.required(),
|
||||||
|
})
|
||||||
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
let data = json!({
|
let data = json!({
|
||||||
"name": function.preferred_name,
|
"name": function.preferred_name,
|
||||||
@ -389,14 +404,7 @@ fn generate_function_from_kcl(
|
|||||||
"deprecated": function.properties.deprecated,
|
"deprecated": function.properties.deprecated,
|
||||||
"fn_signature": function.preferred_name.clone() + &function.fn_signature(),
|
"fn_signature": function.preferred_name.clone() + &function.fn_signature(),
|
||||||
"examples": examples,
|
"examples": examples,
|
||||||
"args": function.args.iter().map(|arg| {
|
"args": args,
|
||||||
json!({
|
|
||||||
"name": arg.name,
|
|
||||||
"type_": arg.ty,
|
|
||||||
"description": arg.docs.clone().or_else(|| arg.ty.as_ref().and_then(|t| super::docs_for_type(t, kcl_std))).unwrap_or_default(),
|
|
||||||
"required": arg.kind.required(),
|
|
||||||
})
|
|
||||||
}).collect::<Vec<_>>(),
|
|
||||||
"return_value": function.return_type.as_ref().map(|t| {
|
"return_value": function.return_type.as_ref().map(|t| {
|
||||||
json!({
|
json!({
|
||||||
"type_": t,
|
"type_": t,
|
||||||
|
@ -167,6 +167,7 @@ impl StdLibFnArg {
|
|||||||
pub fn description(&self, kcl_std: Option<&ModData>) -> Option<String> {
|
pub fn description(&self, kcl_std: Option<&ModData>) -> Option<String> {
|
||||||
// Check if we explicitly gave this stdlib arg a description.
|
// Check if we explicitly gave this stdlib arg a description.
|
||||||
if !self.description.is_empty() {
|
if !self.description.is_empty() {
|
||||||
|
assert!(!self.description.contains('\n'), "Arg docs will get truncated");
|
||||||
return Some(self.description.clone());
|
return Some(self.description.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +152,7 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
|||||||
args = {
|
args = {
|
||||||
sketches = { docs = "Which sketch or sketches should be extruded"},
|
sketches = { docs = "Which sketch or sketches should be extruded"},
|
||||||
length = { docs = "How far to extrude the given sketches"},
|
length = { docs = "How far to extrude the given sketches"},
|
||||||
symmetric = { docs = "If true, the extrusion will happen symmetrically around the sketch. Otherwise, the
|
symmetric = { docs = "If true, the extrusion will happen symmetrically around the sketch. Otherwise, the extrusion will happen on only one side of the sketch." },
|
||||||
extrusion will happen on only one side of the sketch." },
|
|
||||||
bidirectional_length = { docs = "If specified, will also extrude in the opposite direction to 'distance' to the specified distance. If 'symmetric' is true, this value is ignored."},
|
bidirectional_length = { docs = "If specified, will also extrude in the opposite direction to 'distance' to the specified distance. If 'symmetric' is true, this value is ignored."},
|
||||||
tag_start = { docs = "A named tag for the face at the start of the extrusion, i.e. the original sketch" },
|
tag_start = { docs = "A named tag for the face at the start of the extrusion, i.e. the original sketch" },
|
||||||
tag_end = { docs = "A named tag for the face at the end of the extrusion, i.e. the new face created by extruding the original sketch" },
|
tag_end = { docs = "A named tag for the face at the end of the extrusion, i.e. the new face created by extruding the original sketch" },
|
||||||
|
Reference in New Issue
Block a user