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 interface documentation #284

Merged
merged 3 commits into from
Nov 22, 2019
Merged

add interface documentation #284

merged 3 commits into from
Nov 22, 2019

Conversation

apcraig
Copy link
Contributor

@apcraig apcraig commented Nov 18, 2019

PR checklist

  • Short (1 sentence) summary of your PR:
    Add interface documentation and script to generate those interfaces
  • Developer(s):
    tcraig
  • Suggest PR reviewers from list in the column to the right.
  • Please copy the PR test results link or provide a summary of testing completed below.
    No code was changed, but I will run some tests shortly
  • How much do the PR code changes differ from the unmodified code?
    • bit for bit
    • different at roundoff level
    • more substantial
  • Does this PR create or have dependencies on CICE or any other models?
    • Yes
    • No
  • Does this PR add any new test cases?
    • Yes
    • No
  • Is the documentation being updated? ("Documentation" includes information on the wiki or in the .rst files from doc/source/, which are used to create the online technical docs at https://readthedocs.org/projects/cice-consortium-cice/.)
    • Yes
    • No, does the documentation need to be updated at a later time?
      • Yes
      • No
  • Please provide any additional information or relevant details below:

This is related to issue #283. After messing around with sphinx-fortran for many hours, and running into many issues, I decided to implement a short script to extract the public interfaces and add them to the rst documentation. The pluses for using this method are that we control the implementation and it's simple. The minus is that the documentation is not fully automated. A user has to run the script to generate the updated documentation when needed. The problems with sphinx-fortran will be documented in #283 further. This could be just an interim solution.

This meets my primary objective which is to document the public icepack interfaces in the user guide. This does not meet a separate objection which might be to generate a fully interactive copy of the code on the web.

As part of this documentation, we should continue to improve the inline documentation in the public interfaces in the source code, making the subroutine purpose and arguments clearer. Separately, I think we still need to documented the calling sequence for using icepack more generally. There is a place holder in the current documentation for that.

Please see section 3.5 in readthedocs for the latest updates in the documentation including the interfaces.

Copy link
Member

@phil-blain phil-blain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I think it's a very good start.

The minus is that the documentation is not fully automated. A user has to run the script to generate the updated documentation when needed.

It would be relatively easy to write a pre-commit hook that automatically runs the generate_interfaces.sh script before each commit. Hooks have to be installed manually by the developer though, for security purposes, so there is still an initial action needed, although we can document that in our Developer documentation.

This does not meet a separate objection which might be to generate a fully interactive copy of the code on the web.

If we go this way I think we should use something that already exists. Also, the code is already on GitHub, so it is browsable already. If by "interactive" you mean that one could eg. click on a module name in a use statement, or a subroutine name in a call statement to be taken automatically to the file that defines this module/subroutine, that would indeed be useful (and cool!). GitHub is already adding support for that but it's focused on more modern langages at the moment. The underlying infrastructure is open-source, so it may support Fortran one day (one can always wish...)

echo " " >> $rstfile
echo "${title}" >> $rstfile
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $rstfile
echo "::" >> $rstfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing :: to .. code-block:: fortran will make Sphinx syntax highlight the code blocks. I tried it locally and it looks great.
icepack_highlight

I think this would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replied a couple days ago, but maybe didn't push the button. This is a great recommendation and I have implemented it. Thanks!

while IFS= read -r line; do
if [[ $line =~ .*$endline.* ]]; then
dowrite=0
#echo "$dowrite $line"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to keep those commented lines ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the debug lines. I tend to leave them in because they always seem to come in handy later, but understand it's nice to leave it in a cleaner state.

@apcraig
Copy link
Contributor Author

apcraig commented Nov 19, 2019

Regarding automation of documentation generation. Webhooks might work. I was actually thinking about adding an option to cice.build or cice.setup to run the interface documentation script. It could even be done "under the covers" whenever either are run, although I think I prefer an explicit command to trigger it for now. I think the main thing is that we probably won't need to run it too often, so having it done automatically all the time seems a little risky and maybe expensive (think about large test suites although we could turn it off on test suites). Maybe what I'll do is add a new option to cice.setup to support running the documentation script. Then if we decide it should be done automatically, all the time, we could make that happen. Even if cice.setup update the local rst file automatically, it still requires a user to add and commit the change to the rst file in the repo manually. But I guess by running the script automatically, it would highlight times that the file does need to be updated. I'm open on strategy.

@phil-blain
Copy link
Member

Just to clarify: I was referring to Git hooks, which are scripts that run in the local repo.

@apcraig
Copy link
Contributor Author

apcraig commented Nov 19, 2019

I had a look at some githook pre-commit documentation. It looks very cool. It's too bad they can't be added to a repo automatically though. As @phil-blain points out, that creates some extra work. I think I'll just create an option in cice.setup to run the script for now and we can evolve that in the future as we need to.

@apcraig
Copy link
Contributor Author

apcraig commented Nov 19, 2019

I added a --docintfc option to icepack.setup to make updating the icepack public interface documentation a little more straight-forward. I have also updated the documentation to reflect that.

Going back to the full web browsable source code implementation, I agree we should use a tool to do that. I have used doxygen in the past, but there are others. I think we should decide first whether we want to provide that to the community. I personally don't use those kinds of browsing tools, but that doesn't mean we shouldn't do it. I agree with @phil-blain that it would be great if github provided some of the click-thru capability on the site itself as the code is already there.

Copy link
Contributor

@eclare108213 eclare108213 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome

Copy link
Contributor

@duvivier duvivier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apcraig This looks good and I don't have any initial concerns. Have you run RTD with the autogenerated interfaces.rst file? I'd like to see what it looks like before we merge.

@phil-blain
Copy link
Member

phil-blain commented Nov 21, 2019

@duvivier you can see the read-the-docs build by clicking "Show all checks", then "Details" next to the read-the-docs item.
https://external-builds.readthedocs.io/html/cice-consortium-icepack/284/index.html

@duvivier
Copy link
Contributor

@phil-blain I apparently totally blanked about our new and wonderful functionality. (face-palm). I guess that means I'm tired. It looks great.

@apcraig
Copy link
Contributor Author

apcraig commented Nov 21, 2019

@phil-blain thanks for all your feedback. Since you provided some comments before, I'd like to confirm you are comfortable with this PR and we could merge. I'm also happy to consider further updates if you have suggestions. thanks!

Copy link
Member

@phil-blain phil-blain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@apcraig apcraig merged commit f4edf71 into CICE-Consortium:master Nov 22, 2019
@eclare108213 eclare108213 mentioned this pull request Dec 7, 2019
16 tasks
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.

4 participants