Skip to content

Commit f698b05

Browse files
committed
write inline instructions on generating preview of reference (again!)
add temp section: questions to ask section
1 parent 79bacf5 commit f698b05

1 file changed

Lines changed: 73 additions & 33 deletions

File tree

contributor_docs/contributing_to_the_p5js_reference.md

Lines changed: 73 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,10 @@ Multiplies a vector by a scalar and returns a new vector.
223223
224224
A hypertext link HTML element can be used within a function description to link to the documentation of a relevant function or variable.
225225
226-
The url should be of this "fragment" or "hash" form: `#/p5/ + function_or_variable_name`. It should _not_ include a direct link to the website.
226+
The url should be of this "fragment" or "hash" form: `#/p5/ + function_or_variable_name`, e.g. `#/p5/circle`, `#/p5/DEGREES`.
227+
It should _not_ include a direct link to the website.
227228
228-
TODO:
229-
Correct this url rule - the `p5` prefix is not universal. Why, for example, is p5.Vector linked with `#/p5.Vector` and not `#/p5/p5.Vector` (which it resolves to in the website):
230-
```
231-
#/p5.Image
232-
#/p5.Element
233-
#/p5.Texture
234-
#/p5.Framebuffer
235-
#/p5.Vector
236-
#/p5.Renderer
237-
```
238-
END-TODO
229+
TODO: correct this rule. what about p5.Vector, p5.Graphics, etc. what about methods of those classes ? p5.Vector/setMag? static methods?
239230
240231
Examples:
241232
@@ -677,7 +668,7 @@ For more on `describe()` visit the [web accessibility contributor documentation]
677668

678669
With all the above you should have most of the tools needed to write and edit p5.js reference comments. However, there are a few more specialized usages of JSDoc reference comments that you may come across in p5.js. These are situationally useful and not something that you need often.
679670

680-
TODO: perhaps just link here to [./jsdoc.md](./jsdoc.md)?
671+
TODO: either just link here to [./jsdoc.md](./jsdoc.md) or bring all of that into this document.
681672

682673
<!-- TODO: done to this point -->
683674

@@ -763,12 +754,53 @@ Class constructors are defined with the `@class` tag and the `@constructor` tag.
763754
*/
764755
```
765756

766-
767757
## Generating and previewing the reference
768758

769-
In some editors, such as vs code, you can hover over a function or variable to see immediately - in a pop-up - a rendering of the information from the documentation comment above it. This can be a useful first quick preview.
759+
### A quick first in-editor preview for vs code users
760+
761+
In some editors, such as vs code, you can hover over a function or variable to see immediately - in a pop-up - a rendering of the information from the documentation above it. This can be a useful first quick preview, though it won't show everything - it won't run your code examples, or show linked images, for example.
762+
763+
### Previewing your work on the website, locally
764+
765+
At some point you will want to preview how your changes will look on the website. This involves run the website locally and having it import your p5.js code from a branch of your repo.
766+
767+
Note: the following instructions currently co-exist here and in the website repo file: [/docs/scripts.md in the section "testing the docs of your fork"](https://github.com/processing/p5.js-website/blob/2.0/docs/scripts.md#testing-the-docs-of-your-fork)).
768+
(TODO: check what to do about this duplication of preview instructions.)
769+
770+
Steps:
771+
772+
1. Commit your changes to a local branch of your fork of the p5.js repo. The changes don't need to be pushed to github for this purpose, but they do need to be committed on a branch.
773+
1. Clone [the p5.js-website repo](https://github.com/processing/p5.js-website/tree/2.0) locally.
774+
1. In your new p5.js-website repo, check out the branch "2.0".
775+
1. In your new p5.js-website repo, run `npm install`
776+
1. In your new p5.js-website repo, run the following command, using the path to your local p5.js repo before the `#`, and the name of your branch after the `#`:
777+
778+
```sh
779+
npm run custom:dev path/to/local/repo#yourBranch
780+
```
781+
782+
For example, if your work is in a branch called `my-amazing-branch` on a local p5.js repo called `p5.js` as a sibling directory next to the current p5.js-website directory, you could run the following:
783+
784+
```sh
785+
npm run custom:dev ../p5.js#my-amazing-branch
786+
```
787+
788+
This will build the local website reference pages from the data in your branch and start a development preview of the website.
789+
790+
6. Find the URL that is logged in the console and visit it in your browser in order to test out your changes.
791+
792+
If you prefer to preview work that's already on github, you can do so. Use the repo url instead of its local path, as follows:
793+
794+
```sh
795+
npm run custom:dev https://github.com/yourUsername/p5.js.git#yourBranch
796+
```
797+
#### Resetting your changes
798+
799+
When you're done with this preview, you can run this command to reset your changes:
800+
```sh
801+
npm run custom:cleanup
802+
```
770803
771-
To check more thoroughly, it is necessary to use the website software. You can clone and run it locally. There are some convenience scripts to help with pointing it at your repo and branch and starting the server so you can preview your documentation. Instructions for these are in [/docs/scripts.md#testing-the-docs-of-your-fork](https://github.com/processing/p5.js-website/blob/2.0/docs/scripts.md#testing-the-docs-of-your-fork).
772804
773805
## Next steps
774806
@@ -853,14 +885,29 @@ On the p5js repo...
853885
854886
## TODO:
855887
* move this TODO section out before submitting PR
888+
* Finish and place the flow diagrams for doc-gen. ?where?
856889
* Replace first example in Adding examples - it doesn't run no setup or draw. allowed but v unusual in the repo.
857-
* whether to omit @method tag or not?
858-
* update/deprecate @chainable?
859-
* check if we want to encourage text between code examples? (e.g. for gradual introduction and explanation of more complex use-cases). Or is there a risk the user misses critical detail because it was in the "examples" section?
860890
* perhaps acknowledge that there are limits to the types info we can carry in JSDoc and that types are currently sometimes patched in patch.mjs.
891+
* Do a more thorough write-up of how to generate and preview the reference, written for someone who needs to do it to check their work, and has no other instructions.
861892
* address type-generation here? (that the JSDoc comments aren't ONLY used for the reference!)
862893
* find (and use) any recommended mechanism for adding asides as (e.g.) (accessible) default-collapsed sections.
863894
* add section on minimising unnecessary concept dependencies in code examples? Where's the balance between cool examples vs ones that can be most easily understood? What's the line with regard to generating engagement with examples? (If it belongs in the style guide, develop it more there and link to it from here).
895+
* check if tagging incomplete snippets in the markdown as js is harmless (e.g. doesn't break the highlighter library). It provides useful best-effort syntax-highlighting in some contexts, helping to spot errors.
896+
* ? run a comprehensive broken-link check? broken example check? develop one?
897+
* add a ToC? there's one on the side panel but it doesn't give a good overview.
898+
899+
## TODO: Questions to ask
900+
* What's the url-forming rule for in-documentation linking?
901+
```
902+
`#/p5/circle` goes to `p5/circle` but
903+
`#/p5.Vector` goes to `p5/p5.Vector`
904+
??? goes to `p5.Vector/setMag`
905+
??? goes to `p5.Vector/fromAngle`
906+
907+
```
908+
* The existing guide shows how to write examples with no setup or draw fn, which are auto-wrapped in setup. Codebase doesn't use this. Downplay / remove the mention of this mechanism?
909+
* Accept this? "Generally, each example should be a self-contained complete sketch that will run on the reference website and which could be run directly if pasted into the web editor (for example)."
910+
* Accept the following?: Multiple examples are not always separated by @example in the repo. JSDoc says they should be, so i've said that. The guide previously said just put a blank line and then new codeblock.
864911
* assets:
865912
* ? say anything about licensing (e.g. for assets)
866913
* ? say anything about preferred file formats (for size, for browser compat, for licensing?)
@@ -869,17 +916,10 @@ On the p5js repo...
869916
* text size
870917
* color choices (wrt color blindness, also contrast)
871918
* ?reduced-motion?
872-
* ? run a comprehensive broken-link check? broken example check? develop one?
873-
* add a ToC?
874-
* check if tagging incomplete snippets in the markdown as js is harmless (e.g. doesn't break the highlighter library). It provides useful best-effort syntax-highlighting in some contexts, helping to spot errors.
875-
* Do a more thorough write-up of how to generate and preview the reference, written for someone who needs to do it to check their work, and has no other instructions.
876-
* Finish and place the flow diagrams for doc-gen. ?where?
877-
* Document how to link to other related functions from within a function description.
878-
e.g.
879-
```
880-
See the <a href="#/p5/push">push()</a> and <a href="#/p5/pop">pop()</a> functions.
881-
```
882-
* confirm my stipulation of @example between examples - a lot of p5 codebase does this, but the guide previously said just put a blank line and then new codeblock.
883-
* update how to use any asset inside code example
884-
* check assertion: "Generally, each example should be a self-contained complete sketch that will run on the reference website and which could be run directly if pasted into the web editor (for example)." Downplay / remove the mention of excerpt-examples getting automatically wrapped in a new setup() function ?
885-
* Replace use of sin documentation as first encounter? - it's too long and is almost all example code, not doc comment.
919+
920+
### TODO: Questions to ask: low-priority
921+
* Do we want to encourage descriptive text _between_ code examples? (e.g. for gradual introduction and explanation of more complex use-cases). Or is there a risk the user misses critical detail because it was in the "examples" section?
922+
* Non-technical: Replace use of sin documentation as first encounter? - it's too long and is almost all example code, not doc comment.
923+
924+
## Resolved questions
925+
* Whether to recommend omitting @method tag or not? I'm assuming no: its presence reduces ambiguity and helps codebase search.

0 commit comments

Comments
 (0)