Skip to content

Commit 3c637c6

Browse files
committed
Run linter, minor fixes
1 parent 5ad44ff commit 3c637c6

File tree

12 files changed

+111
-122
lines changed

12 files changed

+111
-122
lines changed

codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsDocConverter.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
import org.jsoup.select.NodeVisitor;
2020

2121
/**
22-
* Adds a runtime plugin to set user agent.
22+
* Add a runtime plugin to convert the HTML docs that are provided by services into
23+
* RST
2324
*/
2425
@SmithyInternalApi
2526
public class AwsDocConverter implements PythonIntegration {
@@ -121,7 +122,7 @@ public void tail(Node node, int depth) {
121122
sb.append("``");
122123
break;
123124
case "important":
124-
case "note":
125+
case "note", "p", "li":
125126
sb.append("\n");
126127
break;
127128
case "ul":
@@ -131,9 +132,6 @@ public void tail(Node node, int depth) {
131132
}
132133
sb.append("\n\n");
133134
break;
134-
case "p":
135-
sb.append("\n");
136-
break;
137135
}
138136
}
139137
}

codegen/core/src/main/java/software/amazon/smithy/python/codegen/ClientGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,9 @@ private void writeSharedOperationInit(PythonWriter writer, OperationShape operat
807807
:param plugins: A list of callables that modify the configuration dynamically.
808808
Changes made by these plugins only apply for the duration of the operation
809809
execution and will not affect any other operation invocations.
810-
810+
811811
$L
812-
""",inputDocs, docs);
812+
""", inputDocs, docs);
813813
});
814814

815815
var defaultPlugins = new LinkedHashSet<SymbolReference>();

codegen/core/src/main/java/software/amazon/smithy/python/codegen/generators/SetupGenerator.java

Lines changed: 81 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -275,40 +275,39 @@ private static void writeConf(
275275
String version = settings.moduleVersion();
276276
context.writerDelegator().useFileWriter("docs/conf.py", "", writer -> {
277277
writer.write("""
278-
import os
279-
import sys
280-
sys.path.insert(0, os.path.abspath('..'))
278+
import os
279+
import sys
280+
sys.path.insert(0, os.path.abspath('..'))
281281
282-
project = 'AWS SDK for Python'
283-
author = 'Boto'
284-
release = '$L'
282+
project = 'AWS SDK for Python'
283+
author = 'Boto'
284+
release = '$L'
285285
286-
extensions = [
287-
'sphinx.ext.autodoc',
288-
'sphinx.ext.viewcode',
289-
]
286+
extensions = [
287+
'sphinx.ext.autodoc',
288+
'sphinx.ext.viewcode',
289+
]
290290
291-
templates_path = ['_templates']
292-
exclude_patterns = []
291+
templates_path = ['_templates']
292+
exclude_patterns = []
293293
294-
autodoc_default_options = {
295-
'exclude-members': 'deserialize,deserialize_kwargs,serialize,serialize_members'
296-
}
294+
autodoc_default_options = {
295+
'exclude-members': 'deserialize,deserialize_kwargs,serialize,serialize_members'
296+
}
297297
298-
html_theme = 'pydata_sphinx_theme'
299-
html_theme_options = {
300-
"navbar_center": [],
301-
"logo": {
302-
"text": "AWS SDK for Python",
303-
}
304-
}
298+
html_theme = 'pydata_sphinx_theme'
299+
html_theme_options = {
300+
"navbar_center": [],
301+
"logo": {
302+
"text": "AWS SDK for Python",
303+
}
304+
}
305305
306-
autodoc_typehints = 'both'
307-
""", version);
306+
autodoc_typehints = 'both'
307+
""", version);
308308
});
309309
}
310310

311-
312311
/**
313312
* Write a make.bat file.
314313
* A make.bat file is a batch script used on Windows to build Sphinx documentation.
@@ -321,40 +320,40 @@ private static void writeMakeBat(
321320
) {
322321
context.writerDelegator().useFileWriter("docs/make.bat", "", writer -> {
323322
writer.write("""
324-
@ECHO OFF
323+
@ECHO OFF
325324
326-
pushd %~dp0
325+
pushd %~dp0
327326
328-
REM Command file for Sphinx documentation
327+
REM Command file for Sphinx documentation
329328
330-
if "%SPHINXBUILD%" == "" (
331-
set SPHINXBUILD=sphinx-build
332-
)
333-
set BUILDDIR=build
334-
set SERVICESDIR=source/reference/services
335-
set SPHINXOPTS=-j auto
336-
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
329+
if "%SPHINXBUILD%" == "" (
330+
set SPHINXBUILD=sphinx-build
331+
)
332+
set BUILDDIR=build
333+
set SERVICESDIR=source/reference/services
334+
set SPHINXOPTS=-j auto
335+
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
337336
338-
if "%1" == "" goto help
337+
if "%1" == "" goto help
339338
340-
if "%1" == "clean" (
341-
rmdir /S /Q %BUILDDIR%
342-
goto end
343-
)
339+
if "%1" == "clean" (
340+
rmdir /S /Q %BUILDDIR%
341+
goto end
342+
)
344343
345-
if "%1" == "html" (
346-
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
347-
echo.
348-
echo "Build finished. The HTML pages are in %BUILDDIR%/html."
349-
goto end
350-
)
344+
if "%1" == "html" (
345+
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
346+
echo.
347+
echo "Build finished. The HTML pages are in %BUILDDIR%/html."
348+
goto end
349+
)
351350
352-
:help
353-
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
351+
:help
352+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
354353
355-
:end
356-
popd
357-
""");
354+
:end
355+
popd
356+
""");
358357
});
359358
}
360359

@@ -370,24 +369,23 @@ private static void writeMakeFile(
370369
) {
371370
context.writerDelegator().useFileWriter("docs/Makefile", "", writer -> {
372371
writer.write("""
373-
SPHINXBUILD = sphinx-build
374-
BUILDDIR = build
375-
SERVICESDIR = source/reference/services
376-
SPHINXOPTS = -j auto
377-
ALLSPHINXOPTS = -d $$(BUILDDIR)/doctrees $$(SPHINXOPTS) .
378-
379-
clean:
380-
\t-rm -rf $$(BUILDDIR)/*
381-
382-
html:
383-
\t$$(SPHINXBUILD) -b html $$(ALLSPHINXOPTS) $$(BUILDDIR)/html
384-
\t@echo
385-
\t@echo "Build finished. The HTML pages are in $$(BUILDDIR)/html."
386-
""");
372+
SPHINXBUILD = sphinx-build
373+
BUILDDIR = build
374+
SERVICESDIR = source/reference/services
375+
SPHINXOPTS = -j auto
376+
ALLSPHINXOPTS = -d $$(BUILDDIR)/doctrees $$(SPHINXOPTS) .
377+
378+
clean:
379+
\t-rm -rf $$(BUILDDIR)/*
380+
381+
html:
382+
\t$$(SPHINXBUILD) -b html $$(ALLSPHINXOPTS) $$(BUILDDIR)/html
383+
\t@echo
384+
\t@echo "Build finished. The HTML pages are in $$(BUILDDIR)/html."
385+
""");
387386
});
388387
}
389388

390-
391389
/**
392390
* Write the main index files for the documentation.
393391
* This method creates the main index.rst file and additional index files for
@@ -399,16 +397,16 @@ private static void writeIndexes(GenerationContext context) {
399397
// Write the main index file for the documentation
400398
context.writerDelegator().useFileWriter("docs/index.rst", "", writer -> {
401399
writer.write("""
402-
AWS SDK For Python
403-
====================================================
400+
AWS SDK For Python
401+
====================================================
404402
405-
.. toctree::
406-
:maxdepth: 2
407-
:titlesonly:
408-
:glob:
403+
.. toctree::
404+
:maxdepth: 2
405+
:titlesonly:
406+
:glob:
409407
410-
*/index
411-
""");
408+
*/index
409+
""");
412410
});
413411

414412
// Write the index file for the client section
@@ -429,15 +427,15 @@ private static void writeIndexes(GenerationContext context) {
429427
private static void writeIndexFile(GenerationContext context, String filePath, String title) {
430428
context.writerDelegator().useFileWriter(filePath, "", writer -> {
431429
writer.write("""
432-
$L
433-
=======
434-
.. toctree::
435-
:maxdepth: 1
436-
:titlesonly:
437-
:glob:
438-
439-
*
440-
""", title);
430+
$L
431+
=======
432+
.. toctree::
433+
:maxdepth: 1
434+
:titlesonly:
435+
:glob:
436+
437+
*
438+
""", title);
441439
});
442440
}
443441

codegen/core/src/main/java/software/amazon/smithy/python/codegen/generators/StructureGenerator.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ private void renderStructure() {
103103
writer.pushState(new StructureSection(shape));
104104

105105
writer.write("""
106-
@dataclass(kw_only=True)
107-
class $L:
108-
${C|}
109-
110-
${C|}
111-
112-
${C|}
113-
114-
${C|}
115-
116-
""",
106+
@dataclass(kw_only=True)
107+
class $L:
108+
${C|}
109+
110+
${C|}
111+
112+
${C|}
113+
114+
${C|}
115+
116+
""",
117117
symbol.getName(),
118118
writer.consumer(w -> writeClassDocs(false)),
119119
writer.consumer(w -> writeProperties()),
@@ -160,7 +160,7 @@ class $1L($2T):
160160
writer.consumer(w -> generateDeserializeMethod()));
161161
writer.popState();
162162

163-
}
163+
}
164164

165165
private void writeProperties() {
166166
for (MemberShape member : requiredMembers) {
@@ -317,7 +317,8 @@ private boolean hasDocs() {
317317
private void writeMemberDocs(MemberShape member) {
318318
member.getMemberTrait(model, DocumentationTrait.class).ifPresent(trait -> {
319319
String memberName = symbolProvider.toMemberName(member);
320-
String docs = writer.formatDocs(String.format(":param %s: %s", memberName, trait.getValue())).replace("\n", "\n ");
320+
String docs = writer.formatDocs(String.format(":param %s: %s", memberName, trait.getValue()))
321+
.replace("\n", "\n ");
321322
writer.write(docs);
322323
});
323324
}

codegen/core/src/main/java/software/amazon/smithy/python/codegen/generators/UnionGenerator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import java.util.ArrayList;
88
import java.util.Set;
9-
109
import software.amazon.smithy.codegen.core.SymbolProvider;
1110
import software.amazon.smithy.model.Model;
1211
import software.amazon.smithy.model.shapes.MemberShape;
@@ -133,8 +132,8 @@ raise NotImplementedError()
133132
memberNames.add(unknownSymbol.getName());
134133
writer.popState();
135134

136-
writer.write("type $L = $L\n", parentName, String.join(" | ", memberNames));
137135
writer.pushState(new UnionSection(shape, parentName, memberNames));
136+
writer.write("$L = Union[$L]\n", parentName, String.join(" | ", memberNames));
138137
shape.getTrait(DocumentationTrait.class).ifPresent(trait -> writer.writeDocs(trait.getValue()));
139138
writer.popState();
140139

codegen/core/src/main/java/software/amazon/smithy/python/codegen/integrations/PythonIntegration.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ default Model preprocessModel(Model model, PythonSettings settings) {
4444
return model;
4545
}
4646

47-
4847
/**
4948
* Writes out all extra files required by runtime plugins.
5049
*/

codegen/core/src/main/java/software/amazon/smithy/python/codegen/sections/ErrorSection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
* A section that controls writing an error.
1313
*/
1414
@SmithyInternalApi
15-
public record ErrorSection(Symbol errorSymbol) implements CodeSection {
16-
}
15+
public record ErrorSection(Symbol errorSymbol) implements CodeSection {}

codegen/core/src/main/java/software/amazon/smithy/python/codegen/sections/OperationSection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@
1313
* A section that controls writing an operation.
1414
*/
1515
@SmithyInternalApi
16-
public record OperationSection(Shape service, OperationShape operation) implements CodeSection {
17-
}
16+
public record OperationSection(Shape service, OperationShape operation) implements CodeSection {}

codegen/core/src/main/java/software/amazon/smithy/python/codegen/sections/StructureSection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
* A section that controls writing a structure.
1313
*/
1414
@SmithyInternalApi
15-
public record StructureSection(StructureShape structure) implements CodeSection {
16-
}
15+
public record StructureSection(StructureShape structure) implements CodeSection {}

codegen/core/src/main/java/software/amazon/smithy/python/codegen/sections/UnionMemberSection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
* A section that controls writing a union member.
1313
*/
1414
@SmithyInternalApi
15-
public record UnionMemberSection(Symbol memberSymbol) implements CodeSection {
16-
}
15+
public record UnionMemberSection(Symbol memberSymbol) implements CodeSection {}

0 commit comments

Comments
 (0)