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

Code blocks in docs showing up as single line #30

Open
davepagurek opened this issue Aug 31, 2024 · 2 comments
Open

Code blocks in docs showing up as single line #30

davepagurek opened this issue Aug 31, 2024 · 2 comments

Comments

@davepagurek
Copy link
Contributor

Not sure if we plan on publishing the docs in the out/ folder somewhere, but if so, it looks like multiline code blocks aren't displaying properly. Looks like it's only treating double newlines as a paragraph break, and is squishing single newlines into one outputted line?

image

@tmartinez88
Copy link
Collaborator

confirming the yuidoc html output still looks very strange (worse even, now running the local yuidoc package with npx yuidoc .) when viewing the output html files, not sure what to make of it, will investigate - do you have any clue?

@davepagurek
Copy link
Contributor Author

I think in p5.js, they use yuidoc to generate a json file with all the metadata, and then (in the 1.x main branch anyway) use Backbone.js to render that custom as an editable live sketch. Here, I think yuidoc is directly generating output with a default theme, which seems to be adding paragraphing inside the <code> tag. It looks like replacing <div><code>...</code></div> with <pre><code>...</code></pre> will at least make the output have line breaks:

/**
 * Get the current volume of a sound.
 * @class Amplitude
 * @constructor
 *
 * @example
 * <pre>
 * <code>
 * let sound, amp, cnv;
 *   
 * function preload() {
 *   //replace this sound with something local with rights to distribute
 *   sound = loadSound('https://tonejs.github.io/audio/berklee/gong_1.mp3');
 * }
 * 
 * function setup() {
 *   cnv = createCanvas(100, 100);
 *   cnv.mousePressed(playSound);
 *   textAlign(CENTER);
 *   fill(255);
 *   amp = new Amplitude();
 *   sound.connect(amp);
 * }
 * 
 * function playSound() {
 *   sound.play();
 * }
 * 
 * function draw() {
 *   let level = amp.getLevel();
 *   level = map(level, 0, 0.2, 0, 255);
 *   background(level, 0, 0);
 *   text('tap to play', width/2, 20);
 *   describe('The color of the background changes based on the amplitude of the sound.');
 * }
 * </code>
 * </pre>
 */
class Amplitude {

image

...so if we're OK with having just written code examples and not live interactive sketches, then using a pre tag looks like it'll do the trick. If we want live code examples like in the p5.js repo, we'll maybe have to do a custom theme.

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

No branches or pull requests

2 participants