@@ -35,18 +35,30 @@ def __init__(
35
35
36
36
def prologue (self ) -> None :
37
37
"""Trigger to generate the prolouge code."""
38
- self .target .write (
39
- f"""/**
40
- * Generated by schema-salad code generator
41
- *
42
- * Date: { datetime .date .today ().isoformat ()}
43
- """
44
- )
38
+
39
+ module_comment = []
40
+
41
+ if self .parser_info :
42
+ module_comment .append (self .parser_info + "\n " )
43
+
44
+ module_comment += [
45
+ "This module was generated using schema-salad code generator." ,
46
+ "" ,
47
+ "The embedded document is subject to the license of the original schema." ,
48
+ ]
49
+
45
50
if self .copyright :
46
- self .target .write (f" * Copyright: { self .copyright } \n " )
51
+ module_comment .append (f"The original schema is { self .copyright } ." )
52
+
53
+ module_comment += [
54
+ "" ,
55
+ "License: Apache-2.0" ,
56
+ f"Date: { datetime .date .today ().isoformat ()} " ,
57
+ ]
58
+
59
+ self .target .write (self .to_doc_comment (module_comment ))
47
60
self .target .write (
48
- f""" */
49
- module { self .package } ;
61
+ f"""module { self .package } ;
50
62
51
63
import salad.meta.dumper : genDumper;
52
64
import salad.meta.impl : genCtor, genIdentifier, genOpEq;
@@ -121,7 +133,15 @@ def to_doc_comment(self, doc: Union[None, str, List[str]]) -> str:
121
133
else :
122
134
lines = sum ((d .split ("\n " ) for d in doc ), [])
123
135
124
- doc_lines = "\n " .join ((f" * { line } " for line in lines if line ))
136
+ if not lines [- 1 ]:
137
+ lines = lines [0 :- 1 ]
138
+
139
+ lines = [
140
+ line .replace ("`(`" , "`$(LPAREN)`" ).replace ("`)`" , "`$(RPAREN)`" )
141
+ for line in lines
142
+ ]
143
+
144
+ doc_lines = "\n " .join ((f" * { line } " for line in lines ))
125
145
126
146
return f"""/**
127
147
{ doc_lines }
@@ -248,11 +268,12 @@ def parse_enum(self, stype: Dict[str, Any]) -> str:
248
268
return "\n ///\n public import salad.primitives : Expression;"
249
269
250
270
classname = self .safe_name (name )
251
- syms = [
252
- f' s{ i } = "{ shortname (sym )} "'
253
- for i , sym in enumerate (stype ["symbols" ])
254
- ]
255
- syms_def = ",\n " .join (syms )
271
+ syms = "\n " .join (
272
+ (
273
+ f' s{ i } = "{ shortname (sym )} ", ///'
274
+ for i , sym in enumerate (stype ["symbols" ])
275
+ )
276
+ )
256
277
257
278
if stype .get ("documentRoot" , False ):
258
279
doc_root_annotation = "@documentRoot "
@@ -268,9 +289,10 @@ def parse_enum(self, stype: Dict[str, Any]) -> str:
268
289
return f"""
269
290
{ doc_comment } { doc_root_annotation } class { classname } : SchemaBase
270
291
{{
292
+ ///
271
293
enum Symbol
272
294
{{
273
- { syms_def }
295
+ { syms }
274
296
}}
275
297
276
298
Symbol value;
0 commit comments