Skip to content

Conversation

@thomasarbona
Copy link
Contributor

@thomasarbona thomasarbona commented May 9, 2019

What does this PR do?

  • add "Getting started: React" in Javascript SDK

How should this be manually tested?

  • run npm run dev
  • visit SDK -> Javascript -> Getting Started -> React

Other changes

Improve snippetManager (plugin to import tested snippets in .md):

  • import snippet in another snippet:
    It is not possible with the current syntax to import a tested snippet in a non tested code. With this code for example:
function foo() {
  const x = 2;
  [snippet=random]
}

This produces a very ugly snippet in the browser because this imbricates <pre><code> in another <pre><code>. So, I've implemented a new syntax to import a snippet without wrapping it:

function foo() {
  const x = 2;
  [[snippet=random]]
}

This syntax keeps the indentation of the tag and auto indent the snippet content.

  • only export a subpart of a snippet:
    In order to test a snippet with very specific code (unqualified code for a template), there was no possibility to export only a subpart of the snippet into the generated documentation snippet. So, I've implemented a new syntax in snippets files:
// part I don't want in documentation
this.props = {
  foo: () => {}
};

/* snippet:start */
kuzzle.realtime.subscribe('chat', 'messages', {}, notif => {
  if (notif.type === 'document' && notif.action === 'create') {
    const { _source: message } = notif.result;
    this.props.foo([message]);
  }
});
/* snippet:end */

When we import this snippet in the .md file like this:

async method() {
  [[snippet=subscribe]]
}

This produce the following output:

async method() {
  kuzzle.realtime.subscribe('chat', 'messages', {}, notif => {
    if (notif.type === 'document' && notif.action === 'create') {
      const { _source: message } = notif.result;
      this.props.foo([message]);
    }
  });
}

Boyscout

/

@kuzzle
Copy link
Contributor

kuzzle commented May 9, 2019

Snippets tests reports

SDK Version Tests overview
v6 ✔️
v5 ✔️
v1 ✔️
v1 ✔️
v1 ✔️
v1 ✔️

Copy link
Contributor

@Aschen Aschen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work 🎉

I have another remark about your title, only h2 title are displayed in the right menu
image
It will be better if you split your getting started with h2 title for each subpart of Heart of the subject

@thomasarbona thomasarbona requested a review from Aschen May 10, 2019 11:48
Copy link
Member

@alexandrebouthinon alexandrebouthinon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A cool new feature for snippet templating! Good job 👍

console.log('Success');
kuzzle.disconnect();
}
})();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the real difference between this template and the catch one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catch template expects that the try block fails

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum... the catch template usage is only for auth/createMyCredentials and should be improved but this is indeed out of the scope of the PR.
By having the console.log in the finally statement, the snippet tests will always succeed, regardless if the test actually works, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

thomasarbona and others added 4 commits May 15, 2019 13:02
Co-Authored-By: Benoît Vidis <contact@ben0.fr>
Co-Authored-By: Benoît Vidis <contact@ben0.fr>
Co-Authored-By: Benoît Vidis <contact@ben0.fr>
Co-Authored-By: Benoît Vidis <contact@ben0.fr>
@thomasarbona thomasarbona requested a review from benoitvidis May 15, 2019 11:05
console.log('Success');
kuzzle.disconnect();
}
})();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum... the catch template usage is only for auth/createMyCredentials and should be improved but this is indeed out of the scope of the PR.
By having the console.log in the finally statement, the snippet tests will always succeed, regardless if the test actually works, no?

@benoitvidis benoitvidis merged commit 34856af into 2-dev May 20, 2019
@benoitvidis benoitvidis deleted the getting-started-react branch May 20, 2019 16:16
This was referenced Jun 12, 2019
xbill82 added a commit that referenced this pull request Jun 13, 2019
# [3.0.0](https://github.com/kuzzleio/documentation/releases/tag/3.0.0) (2019-06-12)


#### Bug fixes

- [ [#298](#298) ] Fix bulk import return   ([Aschen](https://github.com/Aschen))
- [ [#325](#325) ] Adapt legacy redirection   ([Aschen](https://github.com/Aschen))
- [ [#322](#322) ] Fix remaining dead links and add check_link to CI   ([Aschen](https://github.com/Aschen))
- [ [#304](#304) ] Fix sdk js tests   ([benoitvidis](https://github.com/benoitvidis))

#### New features

- [ [#299](#299) ] Documentation for wildcard events   ([thomasarbona](https://github.com/thomasarbona))
- [ [#321](#321) ] Add guide about secrets management with the Vault   ([Aschen](https://github.com/Aschen))
- [ [#300](#300) ] Add page about bulk:write and bulk:mwrite   ([Aschen](https://github.com/Aschen))

#### Enhancements

- [ [#327](#327) ] SPA mode   ([xbill82](https://github.com/xbill82))
- [ [#324](#324) ] Update Redis version   ([Aschen](https://github.com/Aschen))
- [ [#316](#316) ] Sdks authenticated connected props   ([Aschen](https://github.com/Aschen))
- [ [#317](#317) ] Add new way for updateSpecifications & validateSpecifications   ([thomasarbona](https://github.com/thomasarbona))
- [ [#296](#296) ] Rewrite the Realtime guide   ([Aschen](https://github.com/Aschen))
- [ [#301](#301) ] Deprecate realtime join   ([Aschen](https://github.com/Aschen))
- [ [#291](#291) ] Getting started React + improve snippetManager   ([thomasarbona](https://github.com/thomasarbona))
- [ [#294](#294) ] Add s3 plugin   ([Aschen](https://github.com/Aschen))
- [ [#292](#292) ] Add since   ([Aschen](https://github.com/Aschen))
- [ [#276](#276) ] [KZL-907] Getting started dev plugin   ([Yoann-Abbes](https://github.com/Yoann-Abbes))
- [ [#284](#284) ] Extending the JS SDK with controllers   ([Aschen](https://github.com/Aschen))
- [ [#271](#271) ] Add documentation page about mappings   ([Aschen](https://github.com/Aschen))

#### Others

- [ [#314](#314) ] Add a clustering guide   ([scottinet](https://github.com/scottinet))
- [ [#319](#319) ] Getting-started-sdk-JS6-architecture   ([berthieresteban](https://github.com/berthieresteban))
- [ [#311](#311) ] Add PDF sending example for Request.setResult   ([Aschen](https://github.com/Aschen))
- [ [#315](#315) ] Normalize directories and generate redirections   ([Aschen](https://github.com/Aschen))
- [ [#309](#309) ] Port #284 to 3-dev   ([berthieresteban](https://github.com/berthieresteban))
- [ [#308](#308) ] Port #283 to 3-dev   ([berthieresteban](https://github.com/berthieresteban))
- [ [#307](#307) ] Port #282 to 3-dev   ([berthieresteban](https://github.com/berthieresteban))
- [ [#306](#306) ] Port #280 to 3-dev   ([berthieresteban](https://github.com/berthieresteban))
- [ [#312](#312) ] Port 278 to 3-dev   ([Aschen](https://github.com/Aschen))
- [ [#310](#310) ] Port #277 to 3-dev   ([Aschen](https://github.com/Aschen))
- [ [#305](#305) ] Port #275 to 3-dev   ([Aschen](https://github.com/Aschen))
- [ [#303](#303) ] Port #274 to 3-dev   ([Aschen](https://github.com/Aschen))
- [ [#302](#302) ] Port #271 to 3-dev   ([Aschen](https://github.com/Aschen))
- [ [#313](#313) ] Port #266 to 3-dev   ([Yoann-Abbes](https://github.com/Yoann-Abbes))
- [ [#290](#290) ] [KZL-1050] Role template example in the documentation   ([Yoann-Abbes](https://github.com/Yoann-Abbes))
- [ [#293](#293) ] [KZL-1036] Add available plugins   ([Yoann-Abbes](https://github.com/Yoann-Abbes))
- [ [#286](#286) ] Embedded protocols   ([benoitvidis](https://github.com/benoitvidis))
---
scottinet pushed a commit to kuzzleio/sdk-javascript that referenced this pull request Oct 11, 2019
## What does this PR do?
Add Kuzzle React getting-started.

This getting-started have been merge in the last doc [#291](kuzzleio/documentation#291)

The last getting started app was builted progressively and some code was rewrite during the reading. 
I had to rewrite lot of parts to remove that because it implicated some untested lines. I avoid hard snippets written in the readme too.

I removed the tested snippets and add cypress to test the app globally.

The app use the current 6-dev sdk version with the ugly post-install line in `doc/6/getting-started/.react/package.json`

### How should this be manually tested?

  - Step 0 : Kuzzle running stack
  - Step 1 : cd doc/6/getting-started/.react
  - Step 2 : yarn install
  - Step 3 : yarn start &  (if error add `SKIP_PREFLIGHT_CHECK=true`)
  - Step 4 : npm run test

### Other changes
/

### Boyscout
/
scottinet pushed a commit to kuzzleio/sdk-javascript that referenced this pull request Oct 11, 2019
## What does this PR do?
Add Kuzzle React getting-started.

This getting-started have been merge in the last doc [#291](kuzzleio/documentation#291)

The last getting started app was builted progressively and some code was rewrite during the reading. 
I had to rewrite lot of parts to remove that because it implicated some untested lines. I avoid hard snippets written in the readme too.

I removed the tested snippets and add cypress to test the app globally.

The app use the current 6-dev sdk version with the ugly post-install line in `doc/6/getting-started/.react/package.json`

### How should this be manually tested?

  - Step 0 : Kuzzle running stack
  - Step 1 : cd doc/6/getting-started/.react
  - Step 2 : yarn install
  - Step 3 : yarn start &  (if error add `SKIP_PREFLIGHT_CHECK=true`)
  - Step 4 : npm run test

### Other changes
/

### Boyscout
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants