Skip to content

Commit c4583e3

Browse files
committed
fix synchronous JSDoc examples to avoid top-level return
1 parent efc670d commit c4583e3

File tree

16 files changed

+331
-208
lines changed

16 files changed

+331
-208
lines changed

packages/components/docs/API.md

Lines changed: 161 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,21 @@ const preExecutionCode = "// About to terminate connection";
209209
const postExecutionCode = "// Connection terminated";
210210
const indent = 2;
211211

212-
return (
213-
<CloseConnection
214-
language={language}
215-
framework={framework}
216-
methodName={methodName}
217-
methodParams={methodParams}
218-
preExecutionCode={preExecutionCode}
219-
postExecutionCode={postExecutionCode}
220-
indent={indent}
221-
/>
222-
);
212+
function renderCloseConnection() {
213+
return (
214+
<CloseConnection
215+
language={language}
216+
framework={framework}
217+
methodName={methodName}
218+
methodParams={methodParams}
219+
preExecutionCode={preExecutionCode}
220+
postExecutionCode={postExecutionCode}
221+
indent={indent}
222+
/>
223+
);
224+
}
225+
226+
renderCloseConnection();
223227
```
224228

225229

@@ -251,12 +255,16 @@ Renders a WebSocket connection method for the specified programming language.
251255
const language = "python";
252256
const title = "HoppscotchEchoWebSocketClient";
253257

254-
return(
255-
<Connect
256-
language={language}
257-
title={title}
258-
/>
259-
)
258+
function renderConnect() {
259+
return(
260+
<Connect
261+
language={language}
262+
title={title}
263+
/>
264+
)
265+
}
266+
267+
renderConnect();
260268
```
261269

262270

@@ -292,14 +300,17 @@ const framework = "quarkus";
292300
const role = "client";
293301
const additionalDependencies = ["import java.util.concurrent.CompletableFuture;", "import java.time.Duration;"];
294302

295-
return (
296-
<DependencyProvider
297-
language={language}
298-
framework={framework}
299-
role={role}
300-
additionalDependencies={additionalDependencies}
301-
/>
302-
)
303+
function renderDependencyProvider() {
304+
return (
305+
<DependencyProvider
306+
language={language}
307+
framework={framework}
308+
role={role}
309+
additionalDependencies={additionalDependencies}
310+
/>
311+
)
312+
}
313+
renderDependencyProvider();
303314
```
304315

305316

@@ -395,16 +406,21 @@ const customMethodConfig = {
395406
methodLogic: "if (cb) cb(message);"
396407
}
397408
};
398-
return (
399-
<HandleMessage
400-
language={language}
401-
methodName={methodName}
402-
methodParams={methodParams}
403-
preExecutionCode={preExecutionCode}
404-
postExecutionCode={postExecutionCode}
405-
customMethodConfig={customMethodConfig}
406-
/>
407-
)
409+
410+
function renderHandleMessage() {
411+
return (
412+
<HandleMessage
413+
language={language}
414+
methodName={methodName}
415+
methodParams={methodParams}
416+
preExecutionCode={preExecutionCode}
417+
postExecutionCode={postExecutionCode}
418+
customMethodConfig={customMethodConfig}
419+
/>
420+
)
421+
}
422+
423+
renderHandleMessage();
408424
```
409425

410426

@@ -454,20 +470,24 @@ const customMethodConfig={ openingTag: "{", closingTag: "}", indentSize: 6 };
454470
const methodConfig = {"java" : {methodDocs : methodDocs, methodLogic: methodLogic }};
455471
const framework = "quarkus";
456472

457-
return (
458-
<MethodGenerator
459-
language={language}
460-
methodName={methodName}
461-
methodParams={methodParams}
462-
methodDocs={methodDocs}
463-
methodLogic={methodLogic}
464-
preExecutionCode={preExecutionCode}
465-
postExecutionCode={postExecutionCode}
466-
customMethodConfig={customMethodConfig}
467-
methodConfig={methodConfig}
468-
framework={framework}
469-
/>
470-
)
473+
function renderMethodGenerator() {
474+
return (
475+
<MethodGenerator
476+
language={language}
477+
methodName={methodName}
478+
methodParams={methodParams}
479+
methodDocs={methodDocs}
480+
methodLogic={methodLogic}
481+
preExecutionCode={preExecutionCode}
482+
postExecutionCode={postExecutionCode}
483+
customMethodConfig={customMethodConfig}
484+
methodConfig={methodConfig}
485+
framework={framework}
486+
/>
487+
)
488+
}
489+
490+
renderMethodGenerator();
471491
```
472492

473493

@@ -555,13 +575,17 @@ const language = "java";
555575
const framework = "quarkus";
556576
const title = "HoppscotchEchoWebSocketClient";
557577

558-
return (
559-
<OnClose
560-
language={language}
561-
framework={framework}
562-
title={title}
563-
/>
564-
)
578+
function renderOnClose() {
579+
return (
580+
<OnClose
581+
language={language}
582+
framework={framework}
583+
title={title}
584+
/>
585+
)
586+
}
587+
588+
renderOnClose();
565589
```
566590

567591

@@ -590,9 +614,14 @@ Renders a WebSocket onError event handler for the specified programming language
590614

591615
```js
592616
const language = "javascript";
593-
return (
594-
<OnError language={language} />
595-
)
617+
618+
function renderOnError() {
619+
return (
620+
<OnError language={language} />
621+
)
622+
}
623+
624+
renderOnError();
596625
```
597626

598627

@@ -621,9 +650,14 @@ Renders a WebSocket onMessage event handler for the specified programming langua
621650

622651
```js
623652
const language = "javascript";
624-
return (
625-
<OnMessage language={language} />
626-
)
653+
654+
function renderOnMessage() {
655+
return (
656+
<OnMessage language={language} />
657+
)
658+
}
659+
660+
renderOnMessage();
627661
```
628662

629663

@@ -657,13 +691,17 @@ const language = "java";
657691
const framework = "quarkus";
658692
const title = "HoppscotchEchoWebSocketClient";
659693

660-
return (
661-
<OnOpen
662-
language={language}
663-
framework={framework}
664-
title={title}
665-
/>
666-
)
694+
function renderOnOpen() {
695+
return (
696+
<OnOpen
697+
language={language}
698+
framework={framework}
699+
title={title}
700+
/>
701+
)
702+
}
703+
704+
renderOnOpen();
667705
```
668706

669707

@@ -796,9 +834,14 @@ Renders a list of core WebSocket client methods for a given target language.
796834

797835
```js
798836
const language = "javascript";
799-
return (
800-
<CoreMethods language={language} />
801-
)
837+
838+
function renderCoreMethods() {
839+
return (
840+
<CoreMethods language={language} />
841+
)
842+
}
843+
844+
renderCoreMethods();
802845
```
803846

804847

@@ -827,9 +870,14 @@ Renders the Installation Command for a given language.
827870

828871
```js
829872
const language = "javascript";
830-
return (
831-
<Installation language={language} />
832-
)
873+
874+
function renderInstallation() {
875+
return (
876+
<Installation language={language} />
877+
)
878+
}
879+
880+
renderInstallation()
833881
```
834882

835883

@@ -1076,13 +1124,17 @@ const clientName = "MyClient";
10761124
const clientFileName = "myClient.js";
10771125
const language = "javascript";
10781126

1079-
return (
1080-
<Usage
1081-
clientName={clientName}
1082-
clientFileName={clientFileName}
1083-
language={language}
1084-
/>
1085-
)
1127+
function renderUsage(){
1128+
return (
1129+
<Usage
1130+
clientName={clientName}
1131+
clientFileName={clientFileName}
1132+
language={language}
1133+
/>
1134+
)
1135+
}
1136+
1137+
renderUsage();
10861138
```
10871139

10881140

@@ -1122,16 +1174,20 @@ const preExecutionCode = "# Pre-register operations";
11221174
const postExecutionCode = "# Post-register operations";
11231175
const customMethodConfig = { returnType: "int", openingTag: "{", closingTag: "}", indentSize: 2};
11241176

1125-
return (
1126-
<RegisterErrorHandler
1127-
language={language}
1128-
methodName={methodName}
1129-
methodParams={methodParams}
1130-
preExecutionCode={preExecutionCode}
1131-
postExecutionCode={postExecutionCode}
1132-
customMethodConfig={customMethodConfig}
1133-
/>
1134-
)
1177+
function renderRegisterErrorHandler() {
1178+
return (
1179+
<RegisterErrorHandler
1180+
language={language}
1181+
methodName={methodName}
1182+
methodParams={methodParams}
1183+
preExecutionCode={preExecutionCode}
1184+
postExecutionCode={postExecutionCode}
1185+
customMethodConfig={customMethodConfig}
1186+
/>
1187+
)
1188+
}
1189+
1190+
renderRegisterErrorHandler();
11351191
```
11361192

11371193

@@ -1169,15 +1225,19 @@ const methodParams = ["self", "handler"];
11691225
const preExecutionCode = "# Pre-register operations";
11701226
const postExecutionCode = "# Post-register operations";
11711227

1172-
return (
1173-
<RegisterMessageHandler
1174-
language={language}
1175-
methodName={methodName}
1176-
methodParams={methodParams}
1177-
preExecutionCode={preExecutionCode}
1178-
postExecutionCode={postExecutionCode}
1179-
/>
1180-
)
1228+
function renderRegisterMessageHandler(){
1229+
return (
1230+
<RegisterMessageHandler
1231+
language={language}
1232+
methodName={methodName}
1233+
methodParams={methodParams}
1234+
preExecutionCode={preExecutionCode}
1235+
postExecutionCode={postExecutionCode}
1236+
/>
1237+
)
1238+
}
1239+
1240+
renderRegisterMessageHandler();
11811241
```
11821242

11831243

packages/components/src/components/CloseConnection.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,21 @@ print('WebSocket connection closed.');`
7979
* const postExecutionCode = "// Connection terminated";
8080
* const indent = 2;
8181
*
82-
* return (
83-
* <CloseConnection
84-
* language={language}
85-
* framework={framework}
86-
* methodName={methodName}
87-
* methodParams={methodParams}
88-
* preExecutionCode={preExecutionCode}
89-
* postExecutionCode={postExecutionCode}
90-
* indent={indent}
91-
* />
92-
* );
82+
* function renderCloseConnection() {
83+
* return (
84+
* <CloseConnection
85+
* language={language}
86+
* framework={framework}
87+
* methodName={methodName}
88+
* methodParams={methodParams}
89+
* preExecutionCode={preExecutionCode}
90+
* postExecutionCode={postExecutionCode}
91+
* indent={indent}
92+
* />
93+
* );
94+
* }
9395
*
96+
* renderCloseConnection();
9497
*/
9598

9699
export function CloseConnection({ methodName = 'close', indent = 2, ...props }) {

0 commit comments

Comments
 (0)