-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
doc: add code example to inspector.url() method #29496
Conversation
ping @Trott |
@nodejs/documentation How do we feel about this sample code? It's not really a runnable code sample. It's really just "Here's what the output would be with three completely different invocations of Node.js." I'm OK with this because it's probably still an improvement over the current doc. But there's probably an even better way to show this that doesn't suggest that the value can change within a single process when it won't? |
@Trott I'm not part of documentation working group, but I could change that JS sintax to Shell, so instead of: // Node.js process was called with --inspect flag.
require('inspector').url()
Debugger listening on ws://127.0.0.1:9229/136e8c71-8901-43d8-b666-1d74a161cd72
For help see https://nodejs.org/en/docs/inspector
ws://127.0.0.1:9229/136e8c71-8901-43d8-b666-1d74a161cd72 Could be more like: $ node --inspect -p "require('inspector').url()"
Debugger listening on ws://127.0.0.1:9229/136e8c71-8901-43d8-b666-1d74a161cd72
For help see https://nodejs.org/en/docs/inspector
ws://127.0.0.1:9229/136e8c71-8901-43d8-b666-1d74a161cd72 |
I could see that being a good option, especially if the commands in question work verbatim on Windows. |
I'm not a Windows expert, but, I'd love to see the @nodejs/documentation opinions before making a new change, but yeah! I can change this for making this better. |
I'm not a Windows expert, but I think those commands would work on Windows too. @nodejs/platform-windows |
This comment has been minimized.
This comment has been minimized.
I found something: "Return the URL of the active inspector, or "Return the URL of the active inspector, |
Pong @Trott |
doc/api/inspector.md
Outdated
@@ -52,6 +52,21 @@ parameter usage. | |||
|
|||
Return the URL of the active inspector, or `undefined` if there is none. | |||
|
|||
```console | |||
$ node --inspect -p "require('inspector').url()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since built-in modules are automatically loaded when Node.js is run this way, we could consider simplifying to something like this here and below?:
$ node --inspect -p "require('inspector').url()" | |
$ node --inspect -p 'inspector.url()' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And adding to the suggested change above, we can make the output easier to read by making it clear what part of the output is from inspector.url()
since there are a couple other lines of output that might confuse the reader?:
$ node --inspect -p "require('inspector').url()" | |
$ node --inspect -p '`\ninspector.url() result: ${inspector.url()}\n`'``` |
That makes the command line a little bit harder to read, but the output easier to read, so...
¯\(ツ)/¯
My comments above are suggestions only. If someone wants to run this on CI and land it as it is right now, I'm fine with that. |
Ping @Trott, I think this is ready, is it? |
Landed in 4113601 |
PR-URL: #29496 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
PR-URL: #29496 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
PR-URL: #29496 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
PR-URL: #29496 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Checklist