Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pacmak): put package README into the right Python module #928

Merged
merged 2 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow!


```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