Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix outdated code-internals guides (#44482)

Jarek Radosz209233c249ff
diff --git a/docs/developer-guides/docs/03-code-internals/03-lint-and-format.md b/docs/developer-guides/docs/03-code-internals/03-lint-and-format.md
index 9e7a91b0936..8fdc5413cec 100644
--- a/docs/developer-guides/docs/03-code-internals/03-lint-and-format.md
+++ b/docs/developer-guides/docs/03-code-internals/03-lint-and-format.md
@@ -47,7 +47,7 @@ bin/lint --fix
When you pass explicit files, `bin/lint` filters them to supported lintable file types before invoking lefthook.
-> :information_source: Markdown documentation files are not currently part of `bin/lint`, so running `bin/lint path/to/doc.md` will report that there are no matching files to lint.
+> :information_source: Markdown files are only linted under `docs/developer-guides/`. Running `bin/lint path/to/doc.md` on any other Markdown file will report that nothing was linted.
## What gets linted
diff --git a/docs/developer-guides/docs/03-code-internals/07-ember-object-ownership.md b/docs/developer-guides/docs/03-code-internals/07-ember-object-ownership.md
index afc11614da5..a038bdd1791 100644
--- a/docs/developer-guides/docs/03-code-internals/07-ember-object-ownership.md
+++ b/docs/developer-guides/docs/03-code-internals/07-ember-object-ownership.md
@@ -42,5 +42,5 @@ To access e.g. services there a couple of methods at your disposal.
- …or if you still need the fallback shim (in a non-component/controller/route/widget context) use
```js
- import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
+ import { getOwnerWithFallback } from "discourse/lib/get-owner";
```
diff --git a/docs/developer-guides/docs/03-code-internals/08-js-performance.md b/docs/developer-guides/docs/03-code-internals/08-js-performance.md
index 06425f3043e..05243f5362f 100644
--- a/docs/developer-guides/docs/03-code-internals/08-js-performance.md
+++ b/docs/developer-guides/docs/03-code-internals/08-js-performance.md
@@ -41,12 +41,18 @@ http://localhost:3000?flag=before
http://localhost:3000?flag=after
```
-If the change is too large for that, then you could clone Discourse into a second directory and launch a **second copy of rails**.
+If the change is too large for that, then you could create a git worktree and launch a **second copy of rails** from it on another port:
```sh
+git worktree add ../discourse-after my-branch
+cd ../discourse-after
+bundle install
+pnpm install
EMBER_ENV=production UNICORN_PORT=3001 bin/dev
```
+Both copies share the same database and Redis, so make sure neither branch has migrations the other doesn't.
+
And then your two URLs would be
```
@@ -90,7 +96,7 @@ This is my `bench.json` file, which will take 300 samples of each target:
To reduce noise, stop any unrelated activities on your workstation, and then start the benchmark with a command like:
```sh
-npx tachometer@latest --config ./bench.json
+pnpx tachometer --config ./bench.json
```
When complete, you should see a comparison of the before/after performance.
@@ -103,6 +109,6 @@ As with any experiments like this, it's worth considering the limitations. For e
- Performance differences on your development workstation may not map directly onto other browsers/devices
-- The boot process of Discourse through the Ember-CLI proxy is not exactly the same as it is in production. When making structural changes (e.g. framework updates) this may be important
+- The boot process of Discourse in development mode is not exactly the same as it is in production. When making structural changes (e.g. framework updates) this may be important
- Performance often varies based on application state (e.g. the number of topics being rendered), so your results may not be exactly reproducible in other environments
diff --git a/docs/developer-guides/docs/03-code-internals/16-creating-routes.md b/docs/developer-guides/docs/03-code-internals/16-creating-routes.md
index 02a8fc43acf..0f1d0ce961a 100644
--- a/docs/developer-guides/docs/03-code-internals/16-creating-routes.md
+++ b/docs/developer-guides/docs/03-code-internals/16-creating-routes.md
@@ -56,7 +56,7 @@ Of course, as you build your feature to add more complexity you likely wouldn’
If you open up your browser and visit `/admin/snack` (without the .json) you’ll see that Discourse says “Oops! That page doesn’t exist.” — that’s because there’s nothing in our front end Ember application to respond to the route. Let’s add a `.gjs` template to show our snack:
-**app/assets/javascripts/admin/templates/snack.gjs**
+**frontend/discourse/admin/templates/snack.gjs**
```gjs
<template>
@@ -68,7 +68,7 @@ If you open up your browser and visit `/admin/snack` (without the .json) you’l
</template>
```
-And, like on the Rails API side we need to wire up the route. Open the file `app/assets/javascripts/admin/routes/admin-route-map.js` and look for the `export default function()` method. Add the following line:
+And, like on the Rails API side we need to wire up the route. Open the file `frontend/discourse/admin/routes/admin-route-map.js` and look for the `export default function()` method. Add the following line:
```js
this.route("snack");
@@ -76,16 +76,17 @@ this.route("snack");
We have one final thing left to do in Ember land, and that’s to have the Ember application perform an AJAX request to fetch our JSON from the server. Let’s create one last file. This will be an [Ember Route](https://guides.emberjs.com/release/routing/specifying-a-routes-model/). Its `model()` function will be called when the route is entered, so we’ll make our `ajax` call in there:
-**app/assets/javascripts/admin/routes/admin-snack.js**
+**frontend/discourse/admin/routes/admin-snack.js**
```js
import { ajax } from "discourse/lib/ajax";
+import DiscourseRoute from "discourse/routes/discourse";
-export default Ember.Route.extend({
+export default class AdminSnackRoute extends DiscourseRoute {
model() {
return ajax("/admin/snack.json");
- },
-});
+ }
+}
```
Now, you can open your browser to `/admin/snack` and you should see the details of the snack rendered in the page!
@@ -96,7 +97,7 @@ Now, you can open your browser to `/admin/snack` and you should see the details
- The Ember application router says `snack` should be the route
-- The Ember.Route for `snack` makes an AJAX request to `/admin/snack.json`
+- The Ember route for `snack` makes an AJAX request to `/admin/snack.json`
- The Rails application router says that should be the `admin_snack controller`