APSIMInitiative / ApsimX

ApsimX is the next generation of APSIM
http://www.apsim.info
Other
137 stars 165 forks source link

PMF class doco for developers #480

Open HamishBrownPFR opened 9 years ago

HamishBrownPFR commented 9 years ago

The view for each PMF class should display some infromation that is useful to developers and is in sync with the source code.

  1. Some instructions that will guide developers but would not be included in science documentation
  2. A list of the classes dependencies
  3. A list of child functions that provide parameters to the class
  4. These need to fit in with the current grid view for setting class properties.

1 could be achieved by picking up some kind of tag out of the source code and displaying it on the class view. Problem is the Science doco already uses the summary tag. Not sure of the solution here 2 could be done by making a list of Link not of type Function 3 could be done by making a list of Links of type Function and also displaying if they are optional or not.

HamishBrownPFR commented 8 years ago

This is now relevant to FunctionL

sno036 commented 8 years ago

Can this be bumped up the priority list (along with all the other top-priority issues :-))?

From Hamish following him fixing one of my simulations: "Someone needs to write a class view for the UI that displays a list of the classes properties and parameters (including units) so you don’t have to go to the source code to work them out. There is an issue (# 480). I suggest posting something on this saying lack of doco is causing problems and this might spur some action in getting it working.

I think you may have inadvertently changed something in you SLURP model under replacements. I deleted this and ran the simulations again (which means it will use the XML in the resources file) and the N taken up numbers became sensible. This is the down side of using the replacements node to view the model, it makes accidental changes possible.

A solution to this would be if the SLURP node (or any crop for that matter) showed the tree view of its structure so users can look at the model and learn how it works but doesn’t allow setting of parameters. Not sure how feasible this is. In the meantime copy a fresh lot of The SLURP xml from the resources file and then comitt. Then if you are getting weird behaviour diff your .apsimx file and check there are not any unintended changes to the Slurp xml."

HamishBrownPFR commented 4 years ago

@hol353 This issue has always bugged me but the need for some better developer info on LifeCycle models has moved it up my priority list. I can have a go at implementing something here but not really sure how the views and presenters work.
Would I be able to have a chat with you at some stage to get some guidance on how best to approach this.

hol353 commented 4 years ago

Happy to have a chat any time. If we can spec it up in sufficient detail then @hol430 could implement. The question is what do we want?

HamishBrownPFR commented 4 years ago

Some updated thoughts following discussion with @hol353 . Need to distinguish between two types of documentation.

  1. Model documentation. This is the documentation that is generated into the .pdf model descriptions and displayed on the website. It describes how a model is configured using memos and class summary fields and documentation methods to construct the pdf.
  2. User instructions. This is what is missing and what we are talking about here. It is to be generated and displayed on the view for each model in the GUI. It describes how to configure a model (as opposed to above which describes how the model is configured). Intent is to use Class remarks field and summary fields on class members to create this. A mock up of how this could look is provided in the figure.

Implementation notes.

HamishBrownPFR commented 4 years ago

@sno036 @jbrider @hut104 FYI if you wish to comment. @hol430 I am hoping you will be able to help implement something here to get this started.

rcichota commented 4 years ago

This looks interesting, and will be very useful. The use of summary and remarks tags seem good in general (I have been populating summary when possible (there is a lot of too generic entries in the code) and I have used remarks quite a bit). A possible issue is that the remarks tag is/can be used for remarks made by the coder for another coder, not necessarily for user documentation. This may not be a big issue as I don't think we have used it much. However, it is my understanding that it is possible to define new tags and then use these as we do with the default ones. We could then define our own tags like "ApsimUserDocumentation" and "ApsimModelDocumentation" to use in our more specific need, instead of re-using the generic ones and risk some confusion...

HamishBrownPFR commented 4 years ago

Thanks for your comments Rogerio. Can you point out any reference on creating custom tags, would be a good approach.

hol430 commented 4 years ago

Isn't this what the documentation on the website is supposed to do?

HamishBrownPFR commented 4 years ago

Sort of but not fully. The destruction being doco on the web site describes how a model is configured as reference for model users. The the intent here is to describe how to configure a model for model developers who build models in the UI but don't read code. One problem we have had with the online doco is getting it tidy because it is a mixture of the two intents and it doesn't address the 2nd one very well.

hol353 commented 4 years ago

The auto-generated tutorials on the web are examples of user documentation e.g. https://apsimdev.apsim.info/ApsimX/Releases/2020.03.25.4946/Report.pdf

hol430 commented 4 years ago

Well there's also the new params/inputs/outputs doco which was only added a few months ago. It sounds similar to this, although I suppose the main difference is that it describes the model's infrastructure/dependencies, rather than being a tutorial (also @hol353 I notice that stddev is not mentioned in section 4.1 of the document you linked).

HamishBrownPFR commented 4 years ago

Another important destinction is this doco is to be located on model views in the UI so it is in a handy location for developers, not generated into pdfs

jbrider commented 4 years ago

Sounds like a great idea - definitely needed.

rcichota commented 4 years ago

Thanks for your comments Rogerio. Can you point out any reference on creating custom tags, would be a good approach.

hmm, I have seen that being said in few places, especially around the xml documentation for C#/VisualStudio (e.g.: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/documentation-comments), but nowhere is shown an actual example. I have added random tags in a c# code for testing and all compiles and behaves without issues. That does not mean one can readily used them, but I'd think one can, as it it were a recommended tag. One issue is how to enforce them, or at least enforce a consistent spelling (tags such as 'summary' appear as suggestion as one types 'su..'), not sure if it is possible to add user defined tags to the list of suggestions...

hol430 commented 4 years ago

A few implementation-related questions:

hol353 commented 4 years ago
zur003 commented 4 years ago

It's possible to do a lot of text formatting using a Gtk TextView widget (although I don't think it handles tables), so that might be a way to avoid some of the problems with HTMLView. Although isn't the main problem with HTMLView that it's difficult to support across platforms?

hol430 commented 4 years ago

If the TextView doesn't support tables then that's probably a deal breaker. On the other hand, the main problems I see with the HTMLView - that is, the difficulty in maintaining and extending it - shouldn't apply here as we'll just be treading the well-beaten path, displaying a few tables and headings, maybe the odd paragraph etc.

Another option would be to construct the view on the fly out of gtk widgets.

hol430 commented 4 years ago

I've created a simple presenter which generates something vaguely resembling Hamish's screenshot above (using the HTMLView). However it's very similar to the params/inputs/outputs docs which are already available on the website. What if we just generate the params/inputs/outputs docs and render to html rather than pdf? Of course, using html still doesn't solve the problem of embedding the grid view or some other property editing mechanism into the view.

image

HamishBrownPFR commented 4 years ago

Thanks @hol430 . What you have there will be enough for me to make a start, I can have a play round with it and work out how it will or won't work. If generating the Params/Inputs/Outputs to HTML is easier or tidier happy to go with that.