Skip to content

Keyword visibility modifiers for resource files #430

Description

@spooning

Originally submitted to Google Code by tookko on 19 Nov 2009

Complicated user keywords in resource files are typically built by
breaking the desired functionality into smaller, lower level user keywords
which are then used by the higher level user keyword. For maintainability
purposes it's often desirable that the lower level keywords are not used
directly from test cases, but only the higher level ones.

While this can be tackled softly by usage of documentation tags, it would
be useful to have a [Private] modifier for keywords, which would make it
not possible to use the keyword from outside the same resource file.

Activity

  1. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 25 Nov 2009

    Resource files, and also variables, lack proper namespace currently. Unfortunately
    fixing all this is a pretty big task and the benefits are relatively small. It's
    unlikely that there's time to resolve this in 2.2.

  2. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 17 Dec 2009

    Issue 449 has been merged into this issue.

  3. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 8 Jan 2012

    Should Robot prevent using private keywords in test cases or other resource files? Or would it be enough just to see this information clearly in documentation and perhaps leave private keywords away from docs generated with libdoc.py?

    Personally I think that the documentation aspect is enough. I don't think preventing people from using keywords they find useful makes anything good. If a keyword is clearly labeled private, users ought to know that using it can be risky and they should contact the author and ask making it public. Importantly the could anyway use the keyword right away. If they couldn't use it directly they would likely copy it somewhere creating unnecessary duplication.

    Another positive side of making this only a documentation aspect is that the implementation is a lot easier.

    Issue 925 proposes an idea to add generic categorization support for keywords. If nobody can give convincing reasons why the framework should prevent using private keywords I'll merge this issue with it.

  4. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by tookko on 13 Jan 2012

    The rationale for blocking access is exactly same as rationale for blocking access to private variables in several programming languages -- to prevent user of the resource file from accidently using the resource file in an untintended way.

    Regarding your statement about contacting author and ask making it public, the same can/should be done independent on whether Robot actually prevents usage or not.

    If you ask me, clear prevention of access would be better, but some users might disagree. A middle road could be logging a warning for using keywords labeled as private.

  5. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 20 Sep 2012

    This would be a really nice feature to have. I target this issue tentatively to 2.8, but cannot promise will it be included in the end. When 2.8 development start is also pretty open.

    See also related issue 1041.

  6. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by c.martin.taylor on 20 Sep 2012

    We use "private" keywords in resource files to implement some of the internals of "visible" keywords. The only way we have of making this happen right now is by putting a big "DON'T USE THIS INTERNAL KEYWORD" message in the documentation. I would suggest something like Python's __KeywordName naming style for indicating private keywords.

  7. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by bryan.oakley on 20 Sep 2012

    FWIW, my team decided to standardize on adding "[tags] tag1, tag2, tag3, ..." to our keyword documentation. We have a custom tool for browsing keywords, and this tool by default hides keywords with this pattern in their documentation. It is working well for us.

  8. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor
  9. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @jussimalinen on 6 Mar 2013

    moving to future. too big for 2.8

  10. pekkaklarck commented on Dec 4, 2014

    @pekkaklarck
    Member

    It probably makes sense to use keyword tags (#925) to mark keywords private. We can either use just private or perhaps add a prefix like rf:private or robot:private that also other possibly needed special tags can use.

    Keyword tags are targeted for RF 2.9, and it would be great if this functionality could be implemented then too. If this feature cannot make to 2.9, we anyway need to think about what tag to use in the future when this actually is implemented.

  11. added this to the 2.9 milestone on Dec 4, 2014
  12. pekkaklarck commented on Jun 24, 2015

    @pekkaklarck
    Member

    Unfortunately no time for this in 2.9.

  13. removed this from the 2.9 milestone on Jun 24, 2015
  14. RedTea14 commented on Aug 20, 2018

    @RedTea14

    What is the status of this problem? Will we include this in a future release?

  15. pekkaklarck commented on Aug 20, 2018

    @pekkaklarck
    Member

    Hopefully this is implemented at some point, but I cannot make any promises when. At least I won't have time to look at this before RF 3.1 and we don't even have plans when to start RF 3.2 development. If this is important for you and you have resources to look at implementing this yourself, I can help you get started and review pull requests.

  16. 29 remaining items

  17. pekkaklarck commented on Jul 4, 2022

    @pekkaklarck
    Member

    Everything I mentioned in by previous comment is now done and I consider this issue done as well. This has been the oldest issue in this issue tracker for some time and it's great to finally get it closed!

    I'll look at #4366 next to avoid warnings if there are public and private keywords with same name in different files. Another thing related to this issue is making it faster to check do keywords and test have special tags.

  18. pekkaklarck commented on Jul 4, 2022

    @pekkaklarck
    Member

    Above commit added private info to Libdoc spec files to make it easier for external tools to check are keywords private. The info is added only if a keyword is private similarly as we only only deprecated when keywords are actually deprecated (#4387).

  19. pekkaklarck commented on Jul 5, 2022

    @pekkaklarck
    Member

    Still more changes to private keywords in the above commits. Now that local keywords in resource files have precedence over imported keywords (#4366), it was possible to remove the warning if there are public and private keywords with the same name. If the private keyword is a local keyword, it can be safely used. Same way if both keywords are imported, it is safe to ignore the private keyword and use the public one without a warning. There is still a warning if there's only one match and that is an imported private keyword.

  20. BCGST commented on Jul 8, 2022

    @BCGST

    I am curious about @tw39124-1's suggestion about import modifiers for resource files. I have recently switched to VS Code to try Robocorp's Language Server and using it has helped me realize that the recursive importation and access to resources can be very unwieldy. All of this to say: Is this a possibility and/or are there existing conversation on "private" importation of resources?

  21. pekkaklarck commented on Jul 8, 2022

    @pekkaklarck
    Member

    There has been some discussion about limiting what's imported but nothing concrete yet. Would you like to start a new thread on our Slack or Forum about this? If you have a concrete proposal, you can also submit a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions