Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add the migration guide and nunjucks depreciation notes #1253

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

Gmin2
Copy link
Collaborator

@Gmin2 Gmin2 commented Aug 11, 2024

Description
Add a migration guide markdown to migrate from nunjucks to react render engine

Related to #1255

Copy link

changeset-bot bot commented Aug 11, 2024

🦋 Changeset detected

Latest commit: cc50175

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/generator Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

sonarcloud bot commented Aug 11, 2024

@Gmin2
Copy link
Collaborator Author

Gmin2 commented Aug 11, 2024

Does i also remove the code that is present for nunjucks render engine too in this PR

cc @derberg @lmgyuan

Copy link
Member

derberg commented Aug 12, 2024

no, we deprecate it now, inform people that removal will take place in a year. So critical is to inform when and what functionality is removed, and how to migrate to alternative - react

Copy link
Collaborator

@Florence-Njeri Florence-Njeri left a comment

Choose a reason for hiding this comment

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

Hey @Gmin2 I have left a few suggestions that you can apply to the doc. The only things I noted are:

  1. We use sentence case for all our docs heading
  2. Ensure consistency in docs especially what you capitalize e.g if Nunjucks is capital in one place, let make it capitalized everywhere

apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

  • have a look on PR from @lmgyuan about cli deprecation. We need similar detailed information here, about deprecation of nunjucks september 2025
  • great we have migration guide, but we also need warning is other generator documents, where nunjucks is explained, and provide clear short note about deprecation, that will link to your guide
  • in migration guide please also point people to https://github.com/asyncapi/template-for-generator-templates and explain that in master branch they see all react-features in use and if they switch to nunjucks branch, they see old features. Basically you did not cover all the features, so safe is to link there as well
  • in guide please mention that nunjucks filters that people placed in filters dir can still be used but as normal functions that you import in your components, and therefore we also recommend to rename them to helpers.
  • in guide mention that hooks stay as they are - no change there as it is not render engine related functionality
  • also in intro of migration guide, and probably also in description of release, please link to https://www.asyncapi.com/blog/react-as-generator-engine article and introduce as an article why we introduced react in 2021 as alternative, and that the same principles apply to remove nunjucks entirely
  • proper code must also be marked as deprecated: https://jsdoc.app/tags-deprecated

@Florence-Njeri in case of CLI deprecation, we no longer mention old ag in docs, only in migration guide. Maybe we should do the same with nunjucks? maybe to make it much easier to maintain documentation, all documentation should be updated and mention react only - except of the guide from @Gmin2 ? For example we probably should:

thoughts?

apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
apps/generator/docs/nunjucka-depreciate.md Outdated Show resolved Hide resolved
}
```

### 4. Macros
Copy link
Member

Choose a reason for hiding this comment

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

@derberg
Copy link
Member

derberg commented Sep 16, 2024

any updates @Gmin2 ?

@Gmin2
Copy link
Collaborator Author

Gmin2 commented Sep 18, 2024

  • have a look on PR from @lmgyuan about cli deprecation. We need similar detailed information here, about deprecation of nunjucks september 2025

@derberg dont you think this needed to be in the issue itself, not in the PR, as this is a migration guide

thoughts @lmgyuan @Florence-Njeri ?

@derberg
Copy link
Member

derberg commented Sep 18, 2024

@Gmin2 that was 3 weeks ago so I don't 100% remember what I was referring to, but afaik, it was about the README.md

@@ -21,6 +22,7 @@ module.exports.registerFilters = async (nunjucks, templateConfig, templateDir, f

/**
* Registers the local template filters.
* @deprecated since version 3.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i have assumed this to be included in the next major release, is this fine @derberg ?

Copy link
Member

Choose a reason for hiding this comment

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

no it won't, so we cannot predict version of the release since it is deprecated

just write @deprecated without any specific note

Copy link
Member

Choose a reason for hiding this comment

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

if jsdocs allows it, please use a link, and text specifying that more info someone can find in https://www.asyncapi.com/docs/tools/generator/nunjucks-react-migration

@Gmin2
Copy link
Collaborator Author

Gmin2 commented Oct 10, 2024

Hey updated the changes, take a look

cc @derberg @Florence-Njeri

README.md Outdated Show resolved Hide resolved

### Conclusion

Migrating from Nunjucks to React templates may require some initial effort, but it will result in more maintainable. You can learn more about why we introduced ther React render engine [here](https://www.asyncapi.com/blog/react-as-generator-engine)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Migrating from Nunjucks to React templates may require some initial effort, but it will result in more maintainable. You can learn more about why we introduced ther React render engine [here](https://www.asyncapi.com/blog/react-as-generator-engine)
Migrating from Nunjucks to React templates may require some initial effort, but it will result in more maintainable. You can learn more about why we introduced ther React render engine [here](https://www.asyncapi.com/blog/react-as-generator-engine)
Suggested change
Migrating from Nunjucks to React templates may require some initial effort, but it will result in more maintainable. You can learn more about why we introduced ther React render engine [here](https://www.asyncapi.com/blog/react-as-generator-engine)
Migrating from Nunjucks to React templates may require some initial effort, but it will result in more maintainable code. You can learn more about why we introduced the React render engine [here](https://www.asyncapi.com/blog/react-as-generator-engine)

Copy link
Member

Choose a reason for hiding this comment

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

@Gmin2 when you apply this change, please also improve the list - as per my other comment about links

Hey @Gmin2, I have left a few suggestions. Please try and run the docs in Grammarly to catch some of the spelling mistakes
@derberg derberg changed the title docs: added the migration guide for depreciation of nunjucks docs: add the migration guide for depreciation of nunjucks Oct 21, 2024
Copy link

sonarcloud bot commented Oct 21, 2024

@derberg derberg changed the title docs: add the migration guide for depreciation of nunjucks fix: add the migration guide and nunjucks depreciation notes Oct 21, 2024
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

@Gmin2 sorry mate but still a bit of work to do

@Florence-Njeri please also have a look, I need you in few areas

@@ -0,0 +1,5 @@
---
"@asyncapi/generator": major
Copy link
Member

Choose a reason for hiding this comment

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

it is not a major release, otherwise we would use ! in the PR title prefix.

Major is when we introduce breaking changes - and here are no breaking changes, we just need to release minor to make sure added deprecation notes are visible to the user in the distro.

Suggested change
"@asyncapi/generator": major
"@asyncapi/generator": minor

weight: 170
---

## Migration Guide from nunjucks render engine to react render engine
Copy link
Member

Choose a reason for hiding this comment

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

please remove

Suggested change
## Migration Guide from nunjucks render engine to react render engine

@Florence-Njeri @Gmin2 below you can see a preview from website, how would this document render - we would have strange duplication.

Screenshot 2024-10-21 at 11 32 23


## Migration Guide from nunjucks render engine to react render engine

### Introduction
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
### Introduction

when you see other generator docs, we don't write "introduction" we just write it without heading

we can of course change it if you think it is wrong, but then it should be a followup PR that unifies approach in all generator docs


### Introduction

The asyncAPI generator is moving away from Nunjucks templates in favor of React templates. This guide will help you migrate your existing Nunjucks templates to React. For a comprehensive understanding of why we introduced React as an alternative in 2021 and why we're now removing Nunjucks entirely, please read our article [React as a Generator Engine](https://www.asyncapi.com/blog/react-as-generator-engine). The principles discussed in this article still apply to our current transition.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The asyncAPI generator is moving away from Nunjucks templates in favor of React templates. This guide will help you migrate your existing Nunjucks templates to React. For a comprehensive understanding of why we introduced React as an alternative in 2021 and why we're now removing Nunjucks entirely, please read our article [React as a Generator Engine](https://www.asyncapi.com/blog/react-as-generator-engine). The principles discussed in this article still apply to our current transition.
The generator is moving away from Nunjucks templates in favor of React templates. This guide will help you migrate your existing Nunjucks templates to React. For a comprehensive understanding of why we introduced React as an alternative in 2021 and why we're now removing Nunjucks entirely, please read our article [React as a Generator Engine](https://www.asyncapi.com/blog/react-as-generator-engine). The principles discussed in this article still apply to our current transition.

"@asyncapi/generator": major
---

Migrating from Nunjucks render engine to React render engine
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Migrating from Nunjucks render engine to React render engine
[Nunjucks render engine](https://www.asyncapi.com/docs/tools/generator/nunjucks-render-engine) is deprecated and will be removed in October 2025. Use [React render engine](https://www.asyncapi.com/docs/tools/generator/react-render-engine) instead. If you already use Nunjucks in production, we have a [migration guide](https://www.asyncapi.com/docs/tools/generator/nunjucks-react-migration) that will help you understand how to migrate to a new engine.

@@ -21,6 +22,7 @@ module.exports.registerFilters = async (nunjucks, templateConfig, templateDir, f

/**
* Registers the local template filters.
* @deprecated since version 3.0
Copy link
Member

Choose a reason for hiding this comment

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

no it won't, so we cannot predict version of the release since it is deprecated

just write @deprecated without any specific note

@@ -21,6 +22,7 @@ module.exports.registerFilters = async (nunjucks, templateConfig, templateDir, f

/**
* Registers the local template filters.
* @deprecated since version 3.0
Copy link
Member

Choose a reason for hiding this comment

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

if jsdocs allows it, please use a link, and text specifying that more info someone can find in https://www.asyncapi.com/docs/tools/generator/nunjucks-react-migration


The asyncAPI generator is moving away from Nunjucks templates in favor of React templates. This guide will help you migrate your existing Nunjucks templates to React. For a comprehensive understanding of why we introduced React as an alternative in 2021 and why we're now removing Nunjucks entirely, please read our article [React as a Generator Engine](https://www.asyncapi.com/blog/react-as-generator-engine). The principles discussed in this article still apply to our current transition.

### Step-by-step migration guide
Copy link
Member

Choose a reason for hiding this comment

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

probably because of my previous comments you will have to do changes to heading sizes, and start this from "##" and update the rest as well

#### 6. File template

The detailed guide on file template can be found in [this](file-templates.md) guide.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#### 7. Models generation
If you have a template written with Nunjucks, it is almost certain that you have your own custom models/classes/types templates in place. Instead of migrating them to React render engine we strongly advise you to delegate models generation to AsyncAPI Modelina project. Learn more on [how to add models generation using Modelina](https://www.asyncapi.com/docs/tools/generator/model-generation).

totally new section that I think is important to have, to safe people time

1. Run the generator using your new React template
2. Compare the output with the previous Nunjucks template output
3. Check for any missing or incorrectly rendered content

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
You might want to consider implementing snapshot tests for your template before starting migration. This will ease the review of changes in content rendered after render engine changes. Snapshot tests allow you to have tests that will persist expected output from Nunjucks template, and compare it with output produced after you do the migration. Check the [example of such snapshot integration test for our internal react template we use for development and testing](https://github.com/asyncapi/generator/blob/master/apps/generator/test/integration.test.js#L66).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants