Skip to content

Commit

Permalink
fix(pacmak): put package README into the right Python module (#928)
Browse files Browse the repository at this point in the history
The (translated) Python README used to be written to the
`<module>._jsii` module, as opposed to the main module.

Put it in the right module where people will actually look for it.
  • Loading branch information
rix0rrr committed Nov 4, 2019
1 parent 9952f86 commit 17dd60f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 29 deletions.
12 changes: 10 additions & 2 deletions packages/jsii-pacmak/lib/targets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,11 @@ class Module implements PythonType {
code.line('publication.publish()');
}

/**
* Emit the README as module docstring if this is the entry point module (it loads the assembly)
*/
private emitModuleDocumentation(code: CodeMaker) {
if (this.package) {
if (this.package && this.loadAssembly && this.package.convertedReadme.trim().length > 0) {
code.line('"""');
code.line(this.package.convertedReadme);
code.line('"""');
Expand Down Expand Up @@ -1466,6 +1469,7 @@ class PythonGenerator extends Generator {
assm,
);

// This is the '<package>._jsii' module
const assemblyModule = new Module(
this.getAssemblyModuleName(assm),
null,
Expand Down Expand Up @@ -1494,12 +1498,16 @@ class PythonGenerator extends Generator {
// actually be generating a module, otherwise we'll generate a class within
// that module.
if (ns === this.assembly.name) {
// This is the main Python entry point (facade to the JSII module)

const module = new Module(
this.assembly.targets!.python!.module,
ns,
{ assembly: this.assembly,
assemblyFilename: this.getAssemblyFileName(),
loadAssembly: ns === this.assembly.name },
loadAssembly: ns === this.assembly.name,
package: this.package
},
);

this.package.addModule(module);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""
"""
import abc
import datetime
import enum
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""
"""
import abc
import datetime
import enum
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
"""
# jsii Calculator
This library is used to demonstrate and test the features of JSII
## Sphinx
This file will be incorporated into the sphinx documentation.
If this file starts with an "H1" line (in our case `# jsii Calculator`), this
heading will be used as the Sphinx topic name. Otherwise, the name of the module
(`jsii-calc`) will be used instead.
## Code Samples
```python
# Example may have issues. See https://github.com/aws/jsii/issues/826
# This is totes a magic comment in here, just you wait!
foo = "bar"
```
"""
import abc
import datetime
import enum
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
"""
# jsii Calculator
This library is used to demonstrate and test the features of JSII
## Sphinx
This file will be incorporated into the sphinx documentation.
If this file starts with an "H1" line (in our case `# jsii Calculator`), this
heading will be used as the Sphinx topic name. Otherwise, the name of the module
(`jsii-calc`) will be used instead.
## Code Samples
```python
# Example may have issues. See https://github.com/aws/jsii/issues/826
# This is totes a magic comment in here, just you wait!
foo = "bar"
```
"""
import abc
import datetime
import enum
Expand Down

0 comments on commit 17dd60f

Please sign in to comment.