You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keyword visibility modifiers for resource files #430
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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?
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.
Activity
spooning commentedon Jun 29, 2014
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.
spooning commentedon Jun 29, 2014
Issue 449 has been merged into this issue.
spooning commentedon Jun 29, 2014
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.
spooning commentedon Jun 29, 2014
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.
spooning commentedon Jun 29, 2014
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.
spooning commentedon Jun 29, 2014
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.
spooning commentedon Jun 29, 2014
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.
spooning commentedon Jun 29, 2014
Having this support in RIDE would be nice too:
https://code.google.com/p/robotframework-ride/issues/detail?id=1189
spooning commentedon Jun 29, 2014
moving to future. too big for 2.8
pekkaklarck commentedon Dec 4, 2014
It probably makes sense to use keyword tags (#925) to mark keywords private. We can either use just
privateor perhaps add a prefix likerf:privateorrobot:privatethat 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.
pekkaklarck commentedon Jun 24, 2015
Unfortunately no time for this in 2.9.
RedTea14 commentedon Aug 20, 2018
What is the status of this problem? Will we include this in a future release?
pekkaklarck commentedon Aug 20, 2018
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.
29 remaining items
Enhance documentation of private user keywords. #430
Smallish cleanup related to private user keywords. #430
pekkaklarck commentedon Jul 4, 2022
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.
Add `private` attribute to Libdoc spec files.
pekkaklarck commentedon Jul 4, 2022
Above commit added
privateinfo 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 onlydeprecatedwhen keywords are actually deprecated (#4387).Give local keywords in resource precedence over imported keywords.
No warning if there is one public and one or more private keywords.
pekkaklarck commentedon Jul 5, 2022
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.
BCGST commentedon Jul 8, 2022
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?
pekkaklarck commentedon Jul 8, 2022
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.
Give precedence to local and public kws over search order.