Skip to content

Commit fd816d7

Browse files
Fix minor formatting and dependency issues
1 parent 382f98e commit fd816d7

File tree

12 files changed

+64
-44
lines changed

12 files changed

+64
-44
lines changed

config/checkstyle/checkstyle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<!-- Files must contain a copyright header, with or without a year. -->
2323
<module name="RegexpHeader">
2424
<property name="header"
25-
value="/\*\n \* Copyright( 20(23)|) Amazon\.com, Inc\. or its affiliates\. All Rights Reserved\.\n"/>
25+
value="/\*\n \* Copyright Amazon\.com, Inc\. or its affiliates\. All Rights Reserved\.\n"/>
2626
<property name="fileExtensions" value="java"/>
2727
</module>
2828

smithy-docgen-core/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ ext {
2222
}
2323

2424
dependencies {
25-
api("software.amazon.smithy:smithy-build:$smithyVersion")
26-
api("software.amazon.smithy:smithy-model:$smithyVersion")
27-
api("software.amazon.smithy:smithy-utils:$smithyVersion")
28-
api("software.amazon.smithy:smithy-codegen-core:$smithyVersion")
25+
implementation("software.amazon.smithy:smithy-build:$smithyVersion")
26+
implementation("software.amazon.smithy:smithy-model:$smithyVersion")
27+
implementation("software.amazon.smithy:smithy-utils:$smithyVersion")
28+
implementation("software.amazon.smithy:smithy-codegen-core:$smithyVersion")
2929
}

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/DirectedDocGen.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
1515

1616
package software.amazon.smithy.docgen.core;
1717

18-
import java.util.ArrayList;
19-
import java.util.List;
2018
import software.amazon.smithy.codegen.core.SymbolProvider;
2119
import software.amazon.smithy.codegen.core.directed.CreateContextDirective;
2220
import software.amazon.smithy.codegen.core.directed.CreateSymbolProviderDirective;
@@ -29,10 +27,8 @@
2927
import software.amazon.smithy.codegen.core.directed.GenerateStructureDirective;
3028
import software.amazon.smithy.codegen.core.directed.GenerateUnionDirective;
3129
import software.amazon.smithy.docgen.core.generators.ServiceGenerator;
32-
import software.amazon.smithy.model.Model;
3330

34-
public class DirectedDocGen
35-
implements DirectedCodegen<DocGenerationContext, DocSettings, DocIntegration> {
31+
public class DirectedDocGen implements DirectedCodegen<DocGenerationContext, DocSettings, DocIntegration> {
3632

3733
@Override
3834
public SymbolProvider createSymbolProvider(CreateSymbolProviderDirective<DocSettings> directive) {
@@ -41,16 +37,13 @@ public SymbolProvider createSymbolProvider(CreateSymbolProviderDirective<DocSett
4137

4238
@Override
4339
public DocGenerationContext createContext(CreateContextDirective<DocSettings, DocIntegration> directive) {
44-
Model model = directive.model();
45-
DocSettings docSettings = directive.settings();
46-
List<DocIntegration> docIntegrations = new ArrayList<>(directive.integrations());
47-
4840
return new DocGenerationContext(
49-
model,
50-
docSettings,
51-
directive.symbolProvider(),
52-
directive.fileManifest(),
53-
docIntegrations);
41+
directive.model(),
42+
directive.settings(),
43+
directive.symbolProvider(),
44+
directive.fileManifest(),
45+
directive.integrations()
46+
);
5447
}
5548

5649
@Override

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/DocGenerationContext.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -24,8 +24,7 @@
2424
import software.amazon.smithy.docgen.core.writers.MarkdownWriter;
2525
import software.amazon.smithy.model.Model;
2626

27-
public final class DocGenerationContext
28-
implements CodegenContext<DocSettings, DocWriter, DocIntegration> {
27+
public final class DocGenerationContext implements CodegenContext<DocSettings, DocWriter, DocIntegration> {
2928
private final Model model;
3029
private final DocSettings docSettings;
3130
private final SymbolProvider symbolProvider;
@@ -44,8 +43,8 @@ public DocGenerationContext(
4443
this.docSettings = docSettings;
4544
this.symbolProvider = symbolProvider;
4645
this.fileManifest = fileManifest;
47-
this.writerDelegator = new WriterDelegator<>(fileManifest, symbolProvider,
48-
new MarkdownWriter.Factory());
46+
// TODO: pull the factory from the integrations
47+
this.writerDelegator = new WriterDelegator<>(fileManifest, symbolProvider, new MarkdownWriter.Factory());
4948
this.docIntegrations = docIntegrations;
5049
}
5150

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/DocIntegration.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -18,6 +18,5 @@
1818
import software.amazon.smithy.codegen.core.SmithyIntegration;
1919
import software.amazon.smithy.docgen.core.writers.DocWriter;
2020

21-
public interface DocIntegration
22-
extends SmithyIntegration<DocSettings, DocWriter, DocGenerationContext> {
21+
public interface DocIntegration extends SmithyIntegration<DocSettings, DocWriter, DocGenerationContext> {
2322
}

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/DocSettings.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -15,12 +15,17 @@
1515

1616
package software.amazon.smithy.docgen.core;
1717

18+
import java.util.Objects;
1819
import software.amazon.smithy.model.node.ObjectNode;
1920
import software.amazon.smithy.model.shapes.ShapeId;
2021

2122
public record DocSettings(ShapeId service) {
23+
24+
public DocSettings {
25+
Objects.requireNonNull(service);
26+
}
27+
2228
public static DocSettings from(ObjectNode pluginSettings) {
23-
return new DocSettings(
24-
pluginSettings.expectStringMember("service").expectShapeId());
29+
return new DocSettings(pluginSettings.expectStringMember("service").expectShapeId());
2530
}
2631
}

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/DocSymbolProvider.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -15,6 +15,9 @@
1515

1616
package software.amazon.smithy.docgen.core;
1717

18+
import static java.lang.String.format;
19+
20+
import java.util.logging.Logger;
1821
import software.amazon.smithy.codegen.core.Symbol;
1922
import software.amazon.smithy.codegen.core.SymbolProvider;
2023
import software.amazon.smithy.model.Model;
@@ -23,6 +26,9 @@
2326
import software.amazon.smithy.model.shapes.ShapeVisitor;
2427

2528
public class DocSymbolProvider extends ShapeVisitor.Default<Symbol> implements SymbolProvider {
29+
30+
private static final Logger LOGGER = Logger.getLogger(DocSymbolProvider.class.getName());
31+
2632
private final Model model;
2733
private final DocSettings docSettings;
2834
private final ServiceShape serviceShape;
@@ -35,7 +41,9 @@ public DocSymbolProvider(Model model, DocSettings docSettings) {
3541

3642
@Override
3743
public Symbol toSymbol(Shape shape) {
38-
return shape.accept(this);
44+
var symbol = shape.accept(this);
45+
LOGGER.fine(() -> format("Creating symbol from %s: %s", shape, symbol));
46+
return symbol;
3947
}
4048

4149
@Override
@@ -48,8 +56,7 @@ public Symbol serviceShape(ServiceShape shape) {
4856
private Symbol.Builder getSymbolBuilder(Shape shape) {
4957
return Symbol.builder()
5058
.name(getShapeName(serviceShape, shape))
51-
.putProperty("shape", shape)
52-
.putProperty("shapeType", shape.getType());
59+
.putProperty("shape", shape);
5360
}
5461

5562
private static String getDefinitionFile(ServiceShape serviceShape, Shape shape) {
@@ -61,11 +68,7 @@ public static String getDefinitionFile(String filename) {
6168
}
6269

6370
private static String getShapeName(ServiceShape serviceShape, Shape shape) {
64-
String name = shape.getId().getName(serviceShape);
65-
if (shape.getId().getMember().isPresent()) {
66-
name += "-" + shape.getId().getMember().get();
67-
}
68-
return name;
71+
return shape.getId().getName(serviceShape);
6972
}
7073

7174
// All other shapes don't get generation, so we'll do null checks where this might

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/SmithyDocPlugin.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
1515

1616
package software.amazon.smithy.docgen.core;
1717

18+
19+
import java.util.logging.Logger;
1820
import software.amazon.smithy.build.PluginContext;
1921
import software.amazon.smithy.build.SmithyBuildPlugin;
2022
import software.amazon.smithy.codegen.core.directed.CodegenDirector;
@@ -25,13 +27,16 @@
2527
*/
2628
public final class SmithyDocPlugin implements SmithyBuildPlugin {
2729

30+
private static final Logger LOGGER = Logger.getLogger(SmithyDocPlugin.class.getName());
31+
2832
@Override
2933
public String getName() {
3034
return "docgen";
3135
}
3236

3337
@Override
3438
public void execute(PluginContext pluginContext) {
39+
LOGGER.fine("Beginning documentation generation.");
3540
DocSettings docSettings = DocSettings.from(pluginContext.getSettings());
3641

3742
CodegenDirector<DocWriter, DocIntegration, DocGenerationContext, DocSettings> runner
@@ -45,5 +50,6 @@ public void execute(PluginContext pluginContext) {
4550
runner.service(docSettings.service());
4651
runner.performDefaultCodegenTransforms();
4752
runner.run();
53+
LOGGER.fine("Finished documentation generation.");
4854
}
4955
}

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/generators/ServiceGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.

smithy-docgen-core/src/main/java/software/amazon/smithy/docgen/core/writers/DocImportContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)