MCPcopy Index your code
hub / github.com/aws/jsii / addJavaDocs

Method addJavaDocs

packages/jsii-pacmak/lib/targets/java.ts:2844–2955  ·  view source on GitHub ↗
(
    doc: spec.Documentable,
    apiLoc: ApiLocation,
    unionHint?: {
      returnsUnion?: spec.TypeReference;
    },
  )

Source from the content-addressed store, hash-verified

2842
2843 // eslint-disable-next-line complexity
2844 private addJavaDocs(
2845 doc: spec.Documentable,
2846 apiLoc: ApiLocation,
2847 unionHint?: {
2848 returnsUnion?: spec.TypeReference;
2849 },
2850 ) {
2851 const returnsUnion =
2852 unionHint?.returnsUnion && containsUnionType(unionHint.returnsUnion)
2853 ? this.renderTypeReference(unionHint.returnsUnion)
2854 : undefined;
2855
2856 if (
2857 !returnsUnion &&
2858 Object.keys(doc.docs ?? {}).length === 0 &&
2859 !((doc as spec.Method).parameters ?? []).some(
2860 (p) => Object.keys(p.docs ?? {}).length !== 0,
2861 )
2862 ) {
2863 return;
2864 }
2865
2866 const docs = (doc.docs = doc.docs ?? {});
2867
2868 const paras = [];
2869
2870 if (docs.summary) {
2871 paras.push(stripNewLines(myMarkDownToJavaDoc(renderSummary(docs))));
2872 }
2873
2874 if (docs.remarks) {
2875 paras.push(
2876 myMarkDownToJavaDoc(
2877 this.convertSamplesInMarkdown(docs.remarks, apiLoc),
2878 ).trimRight(),
2879 );
2880 }
2881
2882 if (returnsUnion) {
2883 paras.push(`Returns union: ${returnsUnion}`);
2884 }
2885
2886 if (docs.default) {
2887 paras.push(`Default: ${docs.default}`); // NOTE: there is no annotation in JavaDoc for this
2888 }
2889
2890 if (docs.example) {
2891 paras.push('Example:');
2892
2893 const convertedExample = this.convertExample(docs.example, apiLoc);
2894
2895 // We used to use the slightly nicer `<pre>{@code ...}</pre>`, which doesn't
2896 // require (and therefore also doesn't allow) escaping special characters.
2897 //
2898 // However, code samples may contain block quotes of their own ('*/') that
2899 // would terminate the block comment from the PoV of the Java tokenizer, and
2900 // since `{@code ... }` doesn't allow any escaping, there's also no way to encode
2901 // '*/' in a way that would (a) hide it from the tokenizer and (b) give '*/' back

Callers 11

onBeginClassMethod · 0.95
onInitializerMethod · 0.95
onBeginEnumMethod · 0.95
onEnumMemberMethod · 0.95
onBeginInterfaceMethod · 0.95
onInterfaceMethodMethod · 0.95
onInterfacePropertyMethod · 0.95
emitConstPropertyMethod · 0.95
emitPropertyMethod · 0.95
emitMethodMethod · 0.95
emitClassBuilderMethod · 0.95

Calls 12

renderTypeReferenceMethod · 0.95
convertExampleMethod · 0.95
paramJavadocMethod · 0.95
containsUnionTypeFunction · 0.90
renderSummaryFunction · 0.90
stripNewLinesFunction · 0.85
myMarkDownToJavaDocFunction · 0.85
escapeFunction · 0.85
escapeEndingCommentFunction · 0.85
filterMethod · 0.80
lineMethod · 0.80

Tested by

no test coverage detected