visit-dav / visit

VisIt - Visualization and Data Analysis for Mesh-based Scientific Data
https://visit.llnl.gov
BSD 3-Clause "New" or "Revised" License
410 stars 110 forks source link

Approach to Python CLI documentation #5012

Open markcmiller86 opened 3 years ago

markcmiller86 commented 3 years ago

Types of CLI Documentation

Requirements for CLI Documentation

We also have some requirements for the CLI documentation (only some of which -- those checked -- are met by current approach):

Observations of Current Approach

Some steps forward

Example of help(GetAnnotationObject) including quickrecipe.rst content

Help on built-in function GetAnnotationObject in module visit:

GetAnnotationObject(...)
    GetAnnotationObject

    Synopsis:

    GetAnnotationObject(string) -> Annotation object

    Arguments:

    string
        The name of the annotation object as returned by GetAnnotationObjectNames.

    Returns:

        GetAnnotationObject returns a reference to an annotation object that was
        created using the CreateAnnotationObject function.

    Description:

    GetAnnotationObject returns a reference to an annotation object that was
    created using the CreateAnnotationObject function. The string
    argument specifies the name of the desired annotation object. It must be
    one of the names returned by GetAnnotationObjectNames. This function is not
    currently necessary unless the annotation object that you used to create an
    annotation has gone out of scope and you need to create another reference
    to the object to set its properties. Also note that although this function
    will apparently also accept an integer index, that mode of access is not
    reliably and should be avoided.

    Adding annotations to your visualization improve the quality of the
    final visualization in that you can refine the colors that you use, add
    logos, or highlight features of interest in your plots. This section
    provides some recipes for creating annotations using scripting.

    Example:

    #% visit -cli
    OpenDatabase("/usr/gapps/visit/data/wave.visit")
    AddPlot("Pseudocolor", "pressure")
    DrawPlots()
    a = CreateAnnotationObject("TimeSlider")
    GetAnnotationObjectNames()
    ["plot0000", "TimeSlider1"]
    ref = GetAnnotationObject("TimeSlider1")
    print(ref)

    Using gradient background colors
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    VisIt’s default white background is not necessarily the best looking
    background color for presentations. Adding a gradient background under
    your plots is an easy way to add a small professional touch to your
    visualizations. VisIt provides a few different styles of gradient
    background: radial, top to bottom, bottom to top, left to right, and
    right to left. The gradient style is set using the
    *gradientBackgroundStyle* member of the AnnotationAttributes object. The
    before and after results are shown in Figure 1

      # Set a blue/black, radial, gradient background.
      a = AnnotationAttributes()
      a.backgroundMode = a.Gradient
      a.gradientBackgroundStyle = a.Radial
      a.gradientColor1 = (0,0,255,255) # Blue
      a.gradientColor2 = (0,0,0,255) # Black
      SetAnnotationAttributes(a)

    Adding a banner
    ~~~~~~~~~~~~~~~
    Banners are useful for providing titles for a visualization or for
    marking its content (see Figure 2) To add an "Unclassified"
    banner to a visualization, use the following bit of Python code:

      # Create a text object that we’ll use to indicate that our
      # visualization is unclassified.
      banner = CreateAnnotationObject("Text2D")
      banner.text = "Unclassified"
      banner.position = (0.37, 0.95)
      banner.fontBold = 1
      # print the attributes that you can set in the banner object.
      print banner

    Adding a time slider
    ~~~~~~~~~~~~~~~~~~~~

    Time sliders are important annotations for movies since they convey how
    much progress an animation has made as well as how many more frames have
    yet to be seen. The time slider is also important for showing the
    simulation time as the animation progresses so users can get a sense of
    when in the simulation important events occur. VisIt’s time slider
    annotation object is shown in Figure 3.
      # Add a time slider in the lower left corner
      slider = CreateAnnotationObject("TimeSlider")
      slider.height = 0.07
      # Print the options that are available in the time slider object
      print slider

    Adding a logo
    ~~~~~~~~~~~~~

    Adding a logo to a visualization is an important part of project
    identification for movies and other visualizations created with VisIt.
    If you have a logo image file stored in TIFF, JPEG, BMP, or PPM format
    then you can use it with VisIt as an image annotation (see Figure 4).
    Note that this approach can
    also be used to insert images of graphs, plots, portraits, diagrams, or
    any other form of image data into a visualization.

      # Incorporate LLNL logo image (llnl.jpeg) as an annotation
      image = CreateAnnotationObject("Image")
      image.image = "llnl.jpeg"
      image.position = (0.02, 0.02)
      # Print the other image annotation options
      print image
markcmiller86 commented 3 years ago

So, after a couple of hours of search for what I thought would be controls on Sphinx/RTD searching features, I discovered that there are special syntaxes to perform partial match searches. I plan on adding a top-level link to this search info so that user's can easily find it.

markcmiller86 commented 3 years ago

I've tried testing the special syntaxes referenced in previous comment. There are some things I honestly cannot confirm are working as advertised. I've filed an issue ticket

biagas commented 3 years ago

Would like to again state my case for keeping quickrecipes: it is good to have simple examples of things you may not know how to search for.

Yes, if you know exactly what you are looking for, a better search engine that finds your example in functions serves that purpose.

However, I often learn unexpected things by perusing simple examples like found in quickrecipes. Something I wasn't necessarily searching for, but useful nonetheless. I would never peruse something so lengthy as our functions documentation. I really only look at it if I know exactly what I need. In light of that, I am opposed to reducing content in quickrecipes.

markcmiller86 commented 3 years ago

Would like to again state my case for keeping quickrecipes: it is good to have simple examples of things you may not know how to search for.

I wanna keep the content (that isn't duplicating content elsewhere). I am advocating for a different (IMHO better) way to handle it.

Yes, if you know exactly what you are looking for, a better search engine that finds your example in functions serves that purpose.

Both of the above statements allude to the impact of search in the decision to structure the docs as they are. That all tells me the root requirement is improved search...not introducing a new place to duplicate content so a usere has more chances of stubmling into it.

However, I often learn unexpected things by perusing simple examples like found in quickrecipes. Something I wasn't necessarily searching for, but useful nonetheless. I would never peruse something so lengthy as our functions documentation. I really only look at it if I know exactly what I need. In light of that, I am opposed to reducing content in quickrecipes

IMHO...the above perspectives suggest some key issues to be solved (did you disagree with any of the requirements above) with the way our CLI docs are structured and that some changes are needed. While the existence of quickrecipes.rst may address some, I think it introduces other issues and I think there is a better solution.

markcmiller86 commented 3 years ago

Does anyone on @visit-dav/visit-developers know if/how we host our docs on closed systems? Do we serve them from a URL of some kind? Do users just browse them via file:// protocol? Have we decided or still working on this? The answer impacts whether a client-side search is more useful way to go.

brugger1 commented 3 years ago

We don’t host them anywhere on the closed systems.

markcmiller86 commented 3 years ago

We don’t host them anywhere on the closed systems.

Hmm...but we still enable users to get to them via GUI Help correct? I mean, that now launches a browser on the manuals, correct?

brugger1 commented 3 years ago

Yes, they are in the GUI help and now that launches a browser on the manuals.

markcmiller86 commented 3 years ago

Yes, they are in the GUI help and now that launches a browser on the manuals.

Just curious...do we know how search works under those conditions (e.g. file:// browsing) ? I am guessing it doesn't work at all or maybe very poorly but don't know for sure. There appears to be some attempt at providing some kind of client-side search but when I try it on static build it just enters an endless Searching... mode.

cyrush commented 3 years ago

I do think search works, there may be a step as part of the build that generates an index that is used?

That said, I personally haven't been very successful with sphinx searching, and I rely on the outline and hunt around. Even for large docs. It can't read your mind (or restated: it doesn't have feedback to discover the most useful common searches) like google.

I don't think the search issue is one we can really make a dent in, or solve by training our users. They aren't going to rely on search if they have a similar experience to mine.

I understand the maintenance burden related to duplication, but several projects provide quick recipes style docs to help get folks going with common use cases. It also provides hope and an expectation that a user should be able to wield these snippets without much mental anguish.

I guess I am not sure what the proposal is, is it to pack quick recipes style info into another place and extract it magically?

As some one who works on multiple projects - the more visit specific sphinx magic exists, the higher the context switching cost for me to contribute is.