99import software .amazon .smithy .codegen .core .directed .GenerateServiceDirective ;
1010import software .amazon .smithy .docgen .core .DocGenerationContext ;
1111import software .amazon .smithy .docgen .core .DocSettings ;
12+ import software .amazon .smithy .docgen .core .sections .ServiceDetailsSection ;
13+ import software .amazon .smithy .docgen .core .sections .ServiceSection ;
1214import software .amazon .smithy .model .shapes .ServiceShape ;
1315import software .amazon .smithy .utils .SmithyInternalApi ;
1416
1517/**
16- * Generates the top-level documentation for a service.
18+ * Generates top-level documentation for the service.
19+ *
20+ * <p>The output of this can be customized in a number of ways. To add details to
21+ * or re-write particular sections, register an interceptor with
22+ * {@link software.amazon.smithy.docgen.core.DocIntegration#interceptors}. The following
23+ * sections are guaranteed to be present:
24+ *
25+ * <ul>
26+ * <li>{@link ServiceDetailsSection}: Enables adding in additional details that are
27+ * inserted after the service's modeled documentation.
28+ * <li>{@link ServiceSection}: Enables re-writing or overwriting the entire page,
29+ * including changes made in other sections.
30+ * </ul>
31+ *
32+ * <p>To change the intermediate format (e.g. from markdown to restructured text),
33+ * a new {@link software.amazon.smithy.docgen.core.DocFormat} needs to be introduced
34+ * via {@link software.amazon.smithy.docgen.core.DocIntegration#docFormats}.
35+ *
36+ * <p>To change the filename or title, implement
37+ * {@link software.amazon.smithy.docgen.core.DocIntegration#decorateSymbolProvider}
38+ * and modify the generated symbol's definition file. See
39+ * {@link software.amazon.smithy.docgen.core.DocSymbolProvider} for details on other
40+ * symbol-driven configuration options.
1741 */
1842@ SmithyInternalApi
1943public final class ServiceGenerator implements Consumer <GenerateServiceDirective <DocGenerationContext , DocSettings >> {
@@ -24,10 +48,12 @@ public void accept(GenerateServiceDirective<DocGenerationContext, DocSettings> d
2448 var serviceSymbol = directive .symbolProvider ().toSymbol (serviceShape );
2549
2650 directive .context ().writerDelegator ().useShapeWriter (serviceShape , writer -> {
51+ writer .pushState (new ServiceSection (directive .service (), directive .context ()));
2752 writer .openHeading (serviceSymbol .getName ());
2853 writer .writeShapeDocs (serviceShape );
29-
54+ writer . injectSection ( new ServiceDetailsSection ( directive . service (), directive . context ()));
3055 writer .closeHeading ();
56+ writer .popState ();
3157 });
3258 }
3359
0 commit comments