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

Add public function documentation script #5253

Merged
merged 12 commits into from
Mar 23, 2019
Merged

Add public function documentation script #5253

merged 12 commits into from
Mar 23, 2019

Conversation

kymckay
Copy link
Member

@kymckay kymckay commented Jun 6, 2017

When merged this pull request will:

  • Remove obsolete event_rename.py script
  • Introduce new python script to the docs/tools directory to generate public function documentation

Current Status:

  • Crawls all function files and identifies which are public
    • Supports optional argument to specify a specific addon to crawl
  • Reports function files with malformed headers
    • Supports optional --debug argument to only check for header issues
    • Missing or misplaced header
    • Missing Public value
    • Invalid Public value
  • Processes the header information
    • Split the header into sections
    • Process the author and description
    • Process the arguments
    • Process the return value
    • Process the example
  • Writes to HTML/whatever

- Currently only finds all public/invalid function files
- Method "document_public" is in place to handle the data taken from a
  function header, but currently unimplemented
@kymckay
Copy link
Member Author

kymckay commented Jun 6, 2017

So, this is a bit of a weird one as I know there are some plans involving the use of http://www.sphinx-doc.org/

I've spent some time messing with that and ran into a few walls so for the time being decided to work on this python script. I've yet to look at what output format we need the data in, but am currently mulling over whether there's a better approach to splitting the header into sections than re.split as it results in the following:

["useless stuff", "Author", "(authors) \n (description text)", "Argument", "(arguments text)", "Return Value", "(return value text)", "Example", "(examples text)", "Public", "(public text)"]

@kymckay
Copy link
Member Author

kymckay commented Nov 28, 2017

So this is basically almost finished, the only question is how we want the data to actually be output. Currently it will spit out .md files (named after component, i.e. medical.md) in the wiki/functions folder of the form:

ace_refuel_fnc_getFuel

Description

Get the remaining fuel amount.

Parameters

Index Description Datatype(s) Default Value
0 Target OBJECT

Return Value

Description Datatype(s)
Fuel left (in liters) NUMBER

Example

[fuelTruck] call ace_refuel_fnc_getFuel

Authors

  • GitHawk
  • Jonpas

ace_refuel_fnc_makeJerryCan

Description

Makes an object into a jerry can.

Parameters

Index Description Datatype(s) Default Value
0 Target OBJECT
1 Fuel amount (in liters) NUMBER

Return Value

None

Example

[can] call ace_refuel_fnc_makeJerryCan

Authors

  • GitHawk

@kymckay
Copy link
Member Author

kymckay commented Nov 28, 2017

It currently just appends to the output files instead of overwriting them, but that should be solvable easily enough

@jonpas
Copy link
Member

jonpas commented Nov 28, 2017

I see you are opening the file for each function, so you'll just have to open it with w flag once before writing first function.

I am not sure what we want to do about removed functions though, I think we're better off just removing them from the doc anyways.

Would this run on Travis? Maybe only on release branch so when we merge release back into master it gets nicely updated at correct time?

@kymckay
Copy link
Member Author

kymckay commented Nov 29, 2017

Yeah, just a question of how best to do the control flow for it. I guess I can just add a quick and dirty solution for now, code can all be refined later.

@thojkooi thojkooi merged commit 0cd904b into master Mar 23, 2019
@thojkooi thojkooi deleted the docs-tool branch March 23, 2019 22:21
@kymckay
Copy link
Member Author

kymckay commented Mar 25, 2019

Oh man this finally got merged? 😆

I can't remember if I wrote this with any semblance of logic, but hopefully it's in a relatively good state. Someone once contacted me on slack to ask for permission to adapt it to their project, may be worth looking into what they did if I can find who that was.

@dedmen
Copy link
Contributor

dedmen commented Mar 26, 2019

Can we get this into CI too? to make sure everyone pushes valid headers?

@jonpas jonpas unassigned bux and kymckay Mar 26, 2019
@jonpas
Copy link
Member

jonpas commented Mar 26, 2019

Make me a separate issue so I don't forget.

@jonpas jonpas mentioned this pull request Mar 26, 2019
2 tasks
BaerMitUmlaut pushed a commit that referenced this pull request Aug 5, 2019
* Remove obsolete event rename script

* Add initial function documenting python script

- Currently only finds all public/invalid function files
- Method "document_public" is in place to handle the data taken from a
  function header, but currently unimplemented

* Add author/description/arguments processing

* Improve console logging and add return processing

* Use class based approach for better data handling

* Add argument processing with support for notes

* Implement rudimentary doc output

* Add return and example processing

* Fix example variable

* Fix documenting no arguments/return

* Fix malformed return handling

* Improve control flow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

5 participants