Closed D4NZ-jpg closed 11 months ago
CompetiTest can be configured to create source files from templates for received problems and contests, see template_file
.
I think it'd be more straightforward to integrate head comments into templates, not only because a single string would make configuration long and unreadable, but also because different filetypes have different comments, e.g. double slash won't work with python.
So the option head_comment
should be substituted by a boolean evaluate_templates
, to let users decide whether to enable this feature or not.
Regarding new modifiers, they should be kept separated from file format modifiers. We already discussed about $(CONTEST)
and $(JUDGE)
modifers in #28 and #29. See also competitive companion format: https://github.com/jmerle/competitive-companion#the-format
I suggest the following receive-modifers, that will be used to evaluate contests_directory
, problems_directory
(from #29) and header comments in template files.
modifier | meaning |
---|---|
$(PROBLEM) |
Problem name, name field |
$(GROUP) |
judge and contest name, group field |
$(JUDGE) |
first part of group , before hyphen |
$(CONTEST) |
second part of group , after hyphen |
$(URL) |
problem url, url field |
$(MEMLIM) |
available memory, memoryLimit field |
$(TIMELIM) |
time limit, timeLimit field |
$(HOME) |
home directory |
$(DATE) |
current time, following date_format |
@D4NZ-jpg wait before proceeding with commits until we reach an agreement about what to do
Now that #40 is closed and receive modifiers (previously called comment modifiers) are implemented, you should rebase this PR or make it from scratch (don't worry, it'll be easier). Here are some suggestions:
date_format
(string) and evaluate_template_modifiers
(boolean) optionslua/competitest/receive.lua
: use eval_receive_modifiers()
to substitute modifiers from loaded file$(DATE)
modifier among the others, get date_format
as function argument in eval_receive_modifiers()
store_problem_config
and store_problem
functionsstore_problem_config
, tclist
, should be replaced by task
, a table with all task detailsGot it. Will make the changes soon.
@xeluxee done, does everything seems okay?
This PR looks ready to be merged
Great, thanks!
I've added this new feature that I personally find really neat to keep track of my solutions, and I think it could benefit others too.
The idea behind this feature is to provide users with the ability to add a header comment at the start of each file automatically. This feature is useful for adding metadata about the problem such as the problem name, group, URL, memory limit, time limit and the starting time.
If you decide to add a comment, you can use specific modifiers to insert dynamic information. For example, you can set the
head_comment
variable to "//This file was generated at $(TIME)
", and it will automatically insert the current time in your preferred format, which can be specified with thetime_format
option, which allows you to specify how you'd like to display the time in your header comment.This feature is not mandatory; if you don't want a comment in your files, just set the
head_comment
variable tofalse
.The way I like to use it is something like this:
which produces something like this on the top of every file: