espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.76k stars 741 forks source link

Links in code reference (and example code) #1498

Open gfwilliams opened 6 years ago

gfwilliams commented 6 years ago

Most of the Espruino reference page is really bad at linking through to other referenced functions. For example NRF.requestDevice may be mentioned in NRF.findDevices, but it should be a link so it can be clicked.

I recently changed the documentation builder so as long as the actual documentation contains the function/class/event's name inside single backticks, it should get automatically linked.

So, please can you flag up if:

Maybe just post up here if you find something? Or you can fix it yourself:

MaBecker commented 6 years ago

something like this?

url: http://www.espruino.com/Reference#ArrayBuffer

link in text:

This is the built-in JavaScript class for array buffers.
If you want to access arrays of differing types of data you may also find /Reference#DataView useful.

points to: http://www.espruino.com/DataView result:

404 - Page Not Found.
If you don't think you should have got this message, please Contact Us and let us know so that we 
can correct the problem!

:

gfwilliams commented 6 years ago

Thanks - I just added a fix for this and some other ArrayBuffer docs

opichals commented 5 years ago

When executed in the JS console on the Reference page

This snippet:

ids = {};
for ([,n] of document.querySelectorAll('a[name]').entries()) {
    ids[n.getAttribute('name')] = n;
}

links = [];
for ([,n] of document.querySelectorAll('a[href]').entries()) {
    links.push(n.getAttribute('href'));
}

localLinks = links.filter(l => l.startsWith('#'));

localLinks.forEach(l => {
    if (!ids[l.slice(1)])
        console.log(`invalid href '${l}'`);
})

outputs the following:

invalid href '#t_l__global_Bluetooth'
invalid href '#t_l__global_I2C1'
invalid href '#t_l__global_I2C2'
invalid href '#t_l__global_I2C3'
invalid href '#t_l__global_LoopbackA'
invalid href '#t_l__global_LoopbackB'
invalid href '#t_l__global_Serial1'
invalid href '#t_l__global_Serial2'
invalid href '#t_l__global_Serial3'
invalid href '#t_l__global_Serial4'
invalid href '#t_l__global_Serial5'
invalid href '#t_l__global_Serial6'
invalid href '#t_l__global_SPI1'
invalid href '#t_l__global_SPI2'
invalid href '#t_l__global_SPI3'
invalid href '#t_l__global_Telnet'
invalid href '#t_l__global_Terminal'
invalid href '#t_l__global_USB'
opichals commented 5 years ago

BTW the https://github.com/espruino/Espruino/issues/1498#issuecomment-418410604 issue seem to still be there.

gfwilliams commented 5 years ago

Thanks - the https://github.com/espruino/Espruino/issues/1498#issuecomment-418410604 is still there because the docs are for 1v99, so the changes I put in aren't in those docs. If you do scripts/build_docs.py then it's fixed.

Good spot on the invalid hrefs though - just fixed that. Again though it won't take effect until the v2.00 release