Closed microbit-matt-hillsdon closed 3 years ago
Status comment (I'll edit this as we go):
Both pretty rough! We could focus on design / layout questions, documentation raising quality, drag-and-drop, progressive disclosure of doc string detail...
If we're generally happy with the direction, and don't seem likely to switch to manually curated docs for this API section, then there's work to be done to tidy up the Pyright side of this too.
I’ve left out modules for now that aren’t in our readthedocs docs: antigravity, builtins, love, this, errno, array, collections, gc, struct, sys.
From discussions with Giles it seems like we might want some docs for the builtins. The stubs currently don't have docs but they exist somewhere...
antigravity and love should probably remain undocumented easter eggs (you can autocomplete to them). The others are probably fine to add but perhaps we'd want to make some modules less prominent as we add more? Though I think a basic/advanced split is harder to justify.
I've truncated them at the moment but that's not really helpful. They're not suitable as-is.
Many don't contain a short summary that we could extract.
There is no systematic approach to parameter documentation.
They contain a lot of restructured text artifacts which we don't yet attempt to format or remove.
It'd be good to discuss what to do here.
I've shown type information. I think it's useful in general but I'm definitely not the target audience. The very few places that use generics look arcane (e.g. random.choose).
Show inherited methods and/or details of the inheritance hierarchy. I think this just applies to the pins in our case.
@microbit-matt-hillsdon this looks excellent, thanks! I'm really surprised by how good it looks and how not overwhelming it is even in this early form. Very promising.
I think you've made a good first pass, and consider this ultimately an editorial choice. I think 'filesystem' probably wants to feature, a I think the accordion doesn't work as well for me because it makes exploration hard, but OTOH the long lists of things like melodies and images slightly confuse the accordionless one. I wonder if there's a version of accordions that is 'auto entering' once one is opened, so you can keep on scrolling as if it's one big list, or contract it? I( can't tell if in practice this will appear to be just the unexpanded list - I think it depends on when the collapse/re-expand happens, and whether you see the rest of the unexpanded items before )
Some simple things/responses to your questions:
I think, as you say, this needs discussion.
What you've generated looks good for giving us an overview and working out what needs to be done. I think you should probably just do as you suggest and create a good one-line summary for each item in the stubs. We can always refine these and it's good to have a starting point.
I think on balance this is confusing. Partly because when is shown there is not the actual text you get in the editor, but without types it's way more similar.
Places that are specifically confusing are things like this:
string: str | float | int
(💠a string, that can also be a float or an int? ) choice(seq: Sequence[_T@choice]) -> _T@choice
(💠whoops, look like the micro:bit Foundation's docs parser broke and there's some mistake in the rendering here)write(self: NeoPixel)
Not sure this is really the fault of the typings, actually.But, the legitimate followup is do we just show parameters only with their name? The ReadTheDocs docs are more verbose, and are name first: (also note the disparity between our autogenerated name for the first parameter and the name in the docs, string
versus value
)
I'd be keen to have some kind of ‘expansion’ where you can see the more detailed info, but kinda think maybe type info could go into the docs
Discussed the latest apidocs and apidocs-accordian branches today and reviewed them alongside autocomplete and signature help (which are on main, but feature flagged).
There was considerable concern about the visual noise from autocomplete and signature help for learners.
We plan to:
At some point we'll look at replacing the accordion with the similar design for the other documentation areas, but we only have wireframes at this point so we should hold off on that.
Other misc todos:
ticks_diff
.Newer feedback that's not yet actionable:
Did a little LSP digging and signature help doesn't contain the name of the function being called, which we need for our approach agreed above. It has a label, which has its type signature and some parameter information (also with types signatures). So this will definitely require changes on the Pyright end on a microbit branch of Pyright. Perhaps we could simply change the label. It seems like we should do the same for autocomplete documentation and share code if they already share code in Pyright.
To link to the "Advanced" docs entry, we'd want to know not just the name but the fully-qualified name. Perhaps we could just do that via Pyright? For autocomplete it's a little awkward as there isn't a discrete field to use. The type signature is currently just the first part of the markdown before the <hr>
.
I'll have a first stab at these Pyright changes tomorrow morning. First of all though, I'll clean up the branch. Now that we can stop maintaining two branches we can tidy up without regard for making merging between them harder.
I think I've got Pyright in a good place to support the changes above. It's now returning a simplified (no defaults) signature for the documentation (still in markdown, we'll have to live with an assumption that it can be parsed out of that).
The signature docs equivalent shows the defaulted parameters too as that might be your actual parameter position.
Both signatures use fully qualified names that we can use to unambiguously link them to our docs.
Looking at active parameter docs, it seems we're not getting them for defaults. It does match the parameter but doesn't seem to return the docs.
This does work in a simple Pylance example so perhaps it's just a trivial error. I'll experiment some more.
The docs are just missing:
Seems likely this was broken by https://github.com/microbit-matt-hillsdon/pyright/commit/1e1a476845ed83eec18562cf9a2921b02a0f68e3 where I unintentionally changed what we pass into the extraction code.
Yep, easy fix:
We've since aligned the Advanced / API documentation with the work-in-progress designs for the other (more beginner-oriented) documentation tabs. See PR #297 which can be previewed here. The micro:bit and Python toolkits are just mock content. The Advanced section is more complete, though we might reconsider the content to make better use of the space in the new design.
Todos from PR that we'll cover off separately. I'm also going to close this initial issue but I'll make sure they all get a home elsewhere.
More for me than the issue tracker:
Raised https://github.com/microbit-foundation/python-editor-next/issues/301 for code pop-up Raised https://github.com/microbit-foundation/python-editor-next/issues/302 for drop-down
Closing this initial prototype issue. Doubtless we'll raise more issues in future, e.g. to cover alignment with final designs and to address how we manage the content backing the micro:bit and Python toolkits, but this one isn't really actionable anymore.
An initial prototype of API documentation in the sidebar that integrates with the editor.
This is early, exploratory work.
Aim to explore: