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

Document esp module for ESP8266 #1289

Closed
wants to merge 1 commit into from
Closed

Document esp module for ESP8266 #1289

wants to merge 1 commit into from

Conversation

deshipu
Copy link
Contributor

@deshipu deshipu commented May 26, 2015

I document as much as I could guess from experiments and reading the
code for the esp module for the ESP8266 port of Micropython.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 93.81% when pulling 76dfe4d on deshipu:master into 967f323 on micropython:master.

@dpgeorge
Copy link
Member

Thanks @deshipu!

Well, these things need to be documented if we want people to be able to actually use this port, and this seems like the right place to put them.

@danicampora Are you going to document the cc3200's specific modules in a similar way?

@danicampora
Copy link
Member

Yes, in fact I am working in the cc3200 docs as we speak ;-). But my current plan is to put everything inside cc3200/docs. I will commit something to my personal repo later today if you want to take a look.

@dpgeorge
Copy link
Member

But my current plan is to put everything inside cc3200/docs

But will they be in Sphinx format? If so, why not make them part of the full docs in docs/?

@danicampora
Copy link
Member

But will they be in Sphinx format?

Yes exactly in the same format as the current docs.

If so, why not make them part of the full docs in docs/?

Because with the CC3200 may things are slitgly different to stmahl (I already made those differences minimal, but still they exist) and many things there apply only to stmhal or a "full" port of uPy.
My quickref has specific details about the WiPy/CC3200 for instance. I think we could get away with sharing many parts of the docs if we modify the structure of the current docs/ folder. We can move the "standard" stuff (usocket, ubinascii, uos, etc) to a common folder.

A quick example, the Pin constructor is different for stmhal, cc3200 and ESP8266. How do you see those 3 ports sharing the same pyb.Pin.rst doc file?

@dpgeorge
Copy link
Member

My quickref has specific details about the WiPy/CC3200 for instance

Yes, we'll need a separate section for the different boards.

quick example, the Pin constructor is different for stmhal, cc3200 and ESP8266.

It should be the same :) ESP is a subset of stmhal, so we can use the same documentation for both with a note for extensions provided by stmhal. Similar situation for cc3200, no?

@danicampora
Copy link
Member

It should be the same :) ESP is a subset of stmhal, so we can use the same documentation for both with a note for extensions provided by stmhal. Similar situation for cc3200, no?

That's the point, it's not "exactly" the same. I think docs are going to be very confusing once we start having more variants which only support a certain subset of the features. In my opinion there should be a separate /doc for the port modules. Otherwise we are going to have to put NOTE: Not supported in... and NOTE: Only supported in.... kind of notes everywhere ;-)

Well, let's see what the others think...

@danicampora
Copy link
Member

Yes, I know this implies having "duplication" in the docs and hence more work for us, but it will also mean having very accurate and easy to read documentation, which I believe is the goal here.

@deshipu
Copy link
Contributor Author

deshipu commented May 27, 2015

How about merging this now, and restructuring the documentation when we know how we want it to look, moving it in the rigth place then?

@danicampora
Copy link
Member

How about merging this now, and restructuring the documentation when we know how we want it to look, moving it in the rigth place then?

Sure, that's fine by me.

@pfalcon
Copy link
Contributor

pfalcon commented May 27, 2015

ESP is a subset of stmhal, so we can use the same documentation for both with a note for extensions provided by stmhal. Similar situation for cc3200, no?

This idea, but the reality about which @danicampora writes is what hold me from better documenting unix port. For example, unix port has termios (or utermios) module. But the main "product" of MicroPython is PyBoard, how useful and non-confusing for PyBoard users would be to read about termios module, even if somewhere there's a fine-print that it's available only in unix port? And that's the simple case, what if methods present/absent, parameters present/absent, behavior is different?

Now that there're 2 "products", I'll let you guys figure out how to deal with that ;-). We need something like #ifdef for Sphinx...

@dhylands
Copy link
Contributor

I actually don't think we want #ifdef for Sphinx. I think we want to document all of the versions.

If people are actually using the unix port, then its definitely useful to document what's actually available and implemented.

@dhylands
Copy link
Contributor

I actually don't think we want #ifdef for Sphinx. I think we want to document all of the ports.

If people are actually using a given port, then its definitely useful to document what's actually available and implemented.

@danicampora
Copy link
Member

I think we want to document all of the versions

+1

And that's the simple case, what if methods present/absent, parameters present/absent, behavior is different?

Looks like @pfalcon and @dhylands are on my side :-)

@deshipu
Copy link
Contributor Author

deshipu commented May 27, 2015

Soo, maybe we could have the available classes/modules documented in individual files (as right now), with notes about differences in how they work, and then have pages for each of the ports, with different TOCs including only the available modules in that port? This way we don't have much duplication, and there is an incentive to make all ports behave the same if possible.

@pfalcon
Copy link
Contributor

pfalcon commented May 27, 2015

I actually don't think we want #ifdef for Sphinx. I think we want to document all of the ports.

Like, for dozen of ports have dozen of doc trees, 90% the same? Or split those 90% out, and have "diff" per-port? Like, 2 method of a module are described in "generic" doc, and 3 in port-specific doc, and let people figure out what's where?

@danicampora
Copy link
Member

Like, for dozen of ports have dozen of doc trees, 90% the same? Or split those 90% out, and have "diff" per-port? Like, 2 method of a module are described in "generic" doc, and 3 in port-specific doc, and let people figure out what's where?

Yeah, both options suck, I agree.

@dhylands
Copy link
Contributor

I think that you use whatever is appropriate.

For example, if the Pin module for PORT-X is virtual identical to stmhal, then it makes sense to say that and list the differences.

If the module doesn't exist anywhere else, then it makes sense to document it in that port.

But not having documentation for the 10% that's different makes it extremely frustrating for users trying to use micropython.

@dhylands
Copy link
Contributor

Another approach is to be able to annotate options to say that a particular option is or isn't implemented on a particular port. (maybe PULL_DOWN gets a little ESP with an X through it or something). Just tossing out ideas.

@danicampora
Copy link
Member

Soo, maybe we could have the available classes/modules documented in individual files (as right now), with notes about differences in how they work, and then have pages for each of the ports, with different TOCs including only the available modules in that port?

Imagine you were not a developer but an user, you just unpacked your uPy powered board and you go to the docs to learn how to use it, and the docs are layout in the way you describe it. How would you feel? Probably a bit frustrated because there's a lot of info that doesn't apply to your board and to find out what it does apply you need to search in many different places.

We are (at least I am ;-)) claiming that Micro Python makes embedding developing easy and fun, and the documents are crucial in making this true.

Maybe the #ifdefs approach is something we need in order to avoid duplication as much as possible, but also a new folder structure.

there is an incentive to make all ports behave the same if possible

This is good and we should aim for that, but it's not always possible. I am changing the CC3200 port a lot to make it's API as similar as possible to stmhal. In many places the case is that I wrote the API to resemble the underlying hardware implementation, which is not always a good choice, then I check stmhal and I see that @dpgeorge approach seems more generic and applicable to other platforms, so I adapt to it. In other places this is just not as easy without scarifying functionality or adding code bloat.

I just feel that if we use 1 doc tree for all ports full of notes about the differences, we are going to have a lot of frustrated users.

@danicampora
Copy link
Member

If we can manage to have a "single" doc source tree that can be used to generate separate htmls for each port (#ifdef like approach), then that's what I think we should do.

@blmorris
Copy link
Contributor

I have never written and deployed a web page for public consumption, so any suggestions I make should be considered with that in mind - but I'm thinking that for sections of the documentation where there is substantial but incomplete overlap between ports we could display all of the text for all of the ports, with a menu to select the port you are interested in, and gray-out the parts that aren't relevant to your port. That way you can see the complete documentation on one page, with the differences clearly displayed in a way that the user can see which parts are relevant to each port.
Not that I have any clue how to implement such a thing, of course.

@danicampora
Copy link
Member

I am looking at the sphinx documentation and I don't see anything that we could use out-of-the-box. I saw the include directive but I don't think it's exactly what we want. Maybe we could add "extra" markups to our .rst files that we parse before passing it to sphinx. Something like:

python makedocs.py --board=wipy

This hypothetical makedocs.py would generate new files that will include all the generic parts and the parts surrounded by #ifdef WIPY (why not? ;-)) and then call sphinx with the resulting files.

@dpgeorge
Copy link
Member

If we go down the route of multiple generated versions of the docs then we probably can't use readthedocs server. That's not a problem (we can use the micropython.org server) but it requires time and effort to set up.

@deshipu
Copy link
Contributor Author

deshipu commented May 27, 2015

If we can manage to have a "single" doc source tree that can be used to generate separate htmls for each port (#ifdef like approach), then that's what I think we should do.

I have never seen a user who would build and read the docs in the tree that he checked out, instead of simply reading it online, when that is available. The only time where we build it is either when we are not online, or when we want to check the changes we just made... So I think we would need to have all those versions online.

There is no #ifdef in sphinx, but you can have different starting documents depending on the configuration, and those starting documents can have different TOCs. The files that are not linked from anywhere will not get build, so you don't have "a lot of info that doesn't apply to your board".

So I think it would make sense to have several starting documents for different boards, with corresponding Sphinx configuration files, and then, on Readthedocs, have several projects, each using the same repository but different configuration file (they allow to change that). Where the starting documents and config files for each of the boards should be located within the filesystem, I'm not sure -- either in the port's docs directory, or inside the global docs, in a subdirectory or not, all make sense to me.

@pfalcon
Copy link
Contributor

pfalcon commented May 27, 2015

If we can manage to have a "single" doc source tree that can be used to generate separate htmls for each port (#ifdef like approach), then that's what I think we should do.

That's exactly what I meant. It also has the important trait @deshipu mentions - "there is an incentive to make all ports behave the same if possible.", while of course being realistic and allow differences in manageable way.

@pfalcon
Copy link
Contributor

pfalcon commented May 27, 2015

but you can have different starting documents depending on the configuration, and those starting documents can have different TOCs. The files that are not linked from anywhere will not get build, so you don't have "a lot of info that doesn't apply to your board".

You miss the point raised above - that same module for different ports may have different contents, different descriptions of each item, etc.

@pfalcon
Copy link
Contributor

pfalcon commented May 27, 2015

There is no #ifdef in sphinx

Any text file (well, almost any), having passed thru C preprocessor, magically acquires that ability.

@deshipu
Copy link
Contributor Author

deshipu commented May 28, 2015

but you can have different starting documents depending on the configuration, and those starting documents can have different TOCs. The files that are not linked from anywhere will not get build, so you don't have "a lot of info that doesn't apply to your board".
You miss the point raised above - that same module for different ports may have different contents, different descriptions of each item, etc.

That's not a problem, just describe the modules that differ in their own files, and include them only in the TOC of the port to which they belong.

@danicampora
Copy link
Member

just describe the modules that differ in their own files.

That's what we want to avoid because many modules share a lot in common with differences here and there, so we want to reuse the documentation of that module as much as possible, only having to write the difss, and then the generated doc of a given board only shows what applies to it.

@deshipu
Copy link
Contributor Author

deshipu commented May 28, 2015

OK, I was wrong, there actually is #ifdef in Sphinx: http://sphinx-doc.org/markup/misc.html#including-content-based-on-tags

@danicampora
Copy link
Member

OK, I was wrong, there actually is #ifdef in Sphinx: http://sphinx-doc.org/markup/misc.html#including-content-based-on-tags

Cool! that seems to be what we need :-)

@dpgeorge
Copy link
Member

there is an incentive to make all ports behave the same if possible

Furthermore, a benefit of having selectively compiled documentation is that it's very easy for developers to see exactly what the differences are between ports. At the moment you'd have to view the code from each port to see how they work, but if they are all documented in the same file then it's much easier.

@danicampora
Copy link
Member

I am going to give it a try using the .. only:: directive, and also reorganize the docs folder structure during the next days, then I'll submit a PR so you can criticize it ;-).

@dpgeorge
Copy link
Member

and also reorganize the docs folder structure

I'd say you don't need to add any directories: everything can go in the top-level docs/library directory. There won't be any name clashes because if 2 ports define the same module then they should both be documented together in the same file (using ..only:: for differences). Any port-specific modules like esp should be globally unique, and there should not be many of these.

@pfalcon
Copy link
Contributor

pfalcon commented May 29, 2015

@deshipu : So, I guess you also may want to play with ::only in "docs/library/index.rst" patch.

@deshipu
Copy link
Contributor Author

deshipu commented May 29, 2015

OK, I made the esp8266 part optional, we will probably want to restructure that when splitting the docs anyways.

@pfalcon
Copy link
Contributor

pfalcon commented May 29, 2015

@deshipu : Sorry for being verbose, but does ::only work as expected? Also, can you please squash your changes into single commit?

@dpgeorge : We're good to merge this then, right?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) to 94.14% when pulling 673a2ba on deshipu:master into c02dc8b on micropython:master.

I document as much as I could guess from experiments and reading the
code for the ``esp`` module for the ESP8266 port of Micropython.

For now the tag has to be set manually with -t option when building,
when we have properly split documentation, there will be a separate
config file for esp8266 with that tag set.
@deshipu
Copy link
Contributor Author

deshipu commented May 30, 2015

@pfalcon Squashed.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 94.14% when pulling a9bd0a8 on deshipu:master into 51726b4 on micropython:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 94.14% when pulling a9bd0a8 on deshipu:master into 51726b4 on micropython:master.

@deshipu
Copy link
Contributor Author

deshipu commented May 30, 2015

@pfalcon Yes, it works as expected. I tested it by temporarily adding tags.add('esp8266') to config.py.

@dpgeorge
Copy link
Member

We're good to merge this then, right?

Yes, but no-one will see the new docs because esp8266 is never defined!

@dpgeorge
Copy link
Member

Merged in 78ccb44.

I renamed the variable to "port_esp8266" since we might also want a unix and windows configuration and the variables "unix" and "windows" could very easily clash with other internal Sphinx variables (so they would now be "port_unix" and "port_windows").

To build with a specific config option turned on use: make SPHINXOPTS="-t port_esp8266" html.

@dpgeorge dpgeorge closed this May 30, 2015
@pfalcon
Copy link
Contributor

pfalcon commented May 30, 2015

Yes, but no-one will see the new docs because esp8266 is never defined!

Someone who cares should set up a new readthedocs project which will build the docs with that tag defined. Ideally, that should be project maintainers, to keep stuff organized, but I guess they don't have time (and if they have, working on e.g. #1295 is more important (at least because it covers something which was in work for 1+ years)).

@dpgeorge
Copy link
Member

Someone who cares should set up a new readthedocs project which will build the docs with that tag defined.

I think having a separate rtd project per port is bloat/overkill/difficult to maintain. Eg you'll need to log into each one to build them when a new release comes out. We need to at least solve this problem for the case of unix, pyboard and wipy docs, and if the solution is scalable then it's easy to add esp8266, teensy, etc.

@deshipu
Copy link
Contributor Author

deshipu commented May 30, 2015

I think that's actually the sanest way to proceed. You don't need separate logins to manage the projects -- they have a working user/ownership system. You don't even need to log in to trigger a build, it's just a POST to a public address. You can even set up github to trigger builds automatically on new commits.

Of course, the "official" docs should probably default to a stable branch -- but that's also easy to setup.

@deshipu
Copy link
Contributor Author

deshipu commented May 30, 2015

We can actually have them as subprojects of the mircopython project, then they will live under the same URL.

@dpgeorge
Copy link
Member

You don't even need to log in to trigger a build, it's just a POST to a public address.

You do need to log in if there is a new release/tag, and then select the new tag in the versions list.

@deshipu
Copy link
Contributor Author

deshipu commented May 30, 2015

@dpgeorge what other options do we have? Do you have an alternate suggestion?

@dpgeorge
Copy link
Member

what other options do we have?

There is always the "do it yourself" option, which I definitely prefer :) Ie host the docs at docs.micropython.org/"port name".

@dpgeorge
Copy link
Member

Proof of concept:

pyboard docs: http://micropython.org/resources/docs/pyboard/
esp docs: http://micropython.org/resources/docs/esp8266/

This is rather easy to automate. Just need to work out how to get the version numbers (and languages) working.

@pfalcon
Copy link
Contributor

pfalcon commented May 30, 2015

That's "do it myself" option ;-). If you can do that, very nice, and looks good!

@deshipu
Copy link
Contributor Author

deshipu commented May 30, 2015

Looks great!

tannewt added a commit to tannewt/circuitpython that referenced this pull request Nov 8, 2018
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

Successfully merging this pull request may close these issues.

None yet

7 participants