mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-15 09:05:25 +00:00
Refer cpython documentation
This commit is contained in:
parent
6b038b867a
commit
25801c84eb
3 changed files with 1359 additions and 1263 deletions
|
@ -453,6 +453,8 @@ class StructVisitor(EmitVisitor):
|
|||
def visitType(self, type, depth=0):
|
||||
if hasattr(type, "doc"):
|
||||
doc = "/// " + type.doc.replace("\n", "\n/// ") + "\n"
|
||||
else:
|
||||
doc = f"/// See also [{type.name}](https://docs.python.org/3/library/ast.html#ast.{type.name})"
|
||||
self.emit(doc, depth)
|
||||
self.visit(type.value, type, depth)
|
||||
|
||||
|
@ -534,11 +536,6 @@ class StructVisitor(EmitVisitor):
|
|||
def sum_with_constructors(self, sum, type, depth):
|
||||
type_info = self.type_info[type.name]
|
||||
rust_name = rust_type_name(type.name)
|
||||
# all the attributes right now are for location, so if it has attrs we
|
||||
# can just wrap it in Attributed<>
|
||||
|
||||
for t in sum.types:
|
||||
self.sum_subtype_struct(type_info, t, rust_name, depth)
|
||||
|
||||
self.emit_attrs(depth)
|
||||
self.emit("#[derive(is_macro::Is)]", depth)
|
||||
|
@ -554,7 +551,12 @@ class StructVisitor(EmitVisitor):
|
|||
self.emit("}", depth)
|
||||
self.emit("", depth)
|
||||
|
||||
for t in sum.types:
|
||||
self.sum_subtype_struct(type_info, t, rust_name, depth)
|
||||
|
||||
|
||||
def sum_subtype_struct(self, sum_type_info, t, rust_name, depth):
|
||||
self.emit(f"""/// See also [{t.name}](https://docs.python.org/3/library/ast.html#ast.{t.name})""", depth)
|
||||
self.emit_attrs(depth)
|
||||
payload_name = f"{rust_name}{t.name}"
|
||||
self.emit(f"pub struct {payload_name}<R = TextRange> {{", depth)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,6 +6,14 @@
|
|||
//!
|
||||
//! [PythonArguments] is replaced by [Arguments]. The new [Arguments] type representation uses a new type
|
||||
//! [ArgWithDefault] to represent arguments with default values. See each type documentation for more details.
|
||||
//!
|
||||
//! A few top-level sum types are renamed to human friendly names.
|
||||
//! [CmpOp] refers `cmpop`
|
||||
//! [UnaryOp] refers `unaryop`
|
||||
//! [BoolOp] refers `boolop`
|
||||
//! [WithItem] refers `withitem`
|
||||
//! [ExceptHandler] refers `excepthandler`
|
||||
//!
|
||||
|
||||
mod builtin;
|
||||
mod generic;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue