Docs: make all API reference examples self-contained

Aperta
#61 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@sadielbartholomew ci sta già lavorando.

Dal 17/4/2020.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

documentation enhancement

Some code examples for functions & methods (etc.) in the API reference of the documentation start from a pre-defined state where required fields have already been setup by unspecified code, e.g. (from here) the cf.Bounds.has_property example begins with an undefined f of nature irrelevant:

>>> f.set_property('project', 'CMIP7')
>>> f.has_property('project')
True

whereas the remainder are 'sefl-contained' in that they can be executed directly without error in Python, assuming only an appropriate environment & having run import cf, e.g (from here) where d is defined before it is used for illustration:

>>> d = cf.Data([[4, 2, 1], [1, 2, 3]], 'metre')
>>> d.unique()
<CF Data: [1, 2, 3, 4] metre>

We should convert those in the former state to the latter state by specifying required setup steps. Not only would it make it more useful to users so they can explore the examples more readily, it is a prerequisite to adding docstring example checking (see #57).

Preferably, fields etc. of the required nature would be created using cf construction methods, to promote those. Failing that, they can be created &/or adapted form one of the cf.example_field field constructs, & as part of this work it may be useful to extend the number of those for variety to minimise such example setup.

Lingua principale
Python
Stelle
150
Fork
23
Merge medio
1g 11h
PR unite (30g)
2

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NCAS-CMS/cf-python

Tutte le issue di NCAS-CMS/cf-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.