doorstop
doorstop copied to clipboard
Rules for prefix, name and number
If I create a document and place a "-" or a "_" in the name, I end up with a problem when I add items:
> doorstop create REQ_INIT ./req_init/
created document: REQ_INIT (@/req_init)
> doorstop add REQ_INIT
added item: REQ_INIT001 (@/req_init/REQ_INIT001.yml)
> doorstop add REQ_INIT
added item: REQ_INIT000 (@/req_init/REQ_INIT000.yml)
> doorstop add REQ_INIT
ERROR: item already exists: /home/user/doorstop/req_init/REQ_INIT000.yml
The problem seems to be related to the regular expressions in doorstop/core/types.py, function split_uid. In this example, the regex doesn't find the number at the end of each item, so it ends up as "-1" in the code. I can solve the problem by adding --separator - to the create command. Then the items will be called REQ_INIT-001, etc. The regex is able to cope with this. But perhaps we should do something in the doorstop code so that the user doesn't end up in the problem above without realizing why. I suggest that we either
- allow "-" and "_" in the document name and then update the regex to work with this, or
- we add an error message if the user tries to create a document with "-" or "_" in the name without specifying a separator.
For alternative 1, I need to understand the concept with custom item names, i.e. the -n argument to doorstop add. There are quite a few variations in the unit test for this and I suppose they should all work also afterwards if we change the regex.
Can you try removing the characters that you don't want as separators from the SEP_CHARS
line in settings.py
?
Also, after you doorstop create
is complete, you can edit ./req_init/.doorstop.yml
to specify the separator that you want for that document.
If I remove "_" from SEP_CHARS I can create a document named e.g. "REQ_INIT" and add items to it without problems. But do you mean that this is something we should to in the github version of Doorstop?
Yes, I can change the separator in .doorstop.yml and at the moment I have recommended my colleagues to always use "-" as separators when they create a document. So what is the recommendation in the generic case? Should Doorstop support documents without separator and a name with "_" in it?
But do you mean that this is something we should to in the github version of Doorstop?
Oh, I meant in site-packages/doorstop/settings.py
after install doorstop from pip.
I've been meaning to write up an issue for Doorstop to better handle settings.
I see. I think in my case it will be easier to always use "-" as a separator when creating documents. But I think we should do something to avoid a user ending up with the problem I described in my first comment above. Doorstop out-of-the-box does at the moment not work well when creating a document with a name including e.g. "_" and without a separator.