Skip to content

Commit ab5d44f

Browse files
committed
[conf] Tweak OKR schema
1 parent 2ff1eb5 commit ab5d44f

File tree

3 files changed

+38
-50
lines changed

3 files changed

+38
-50
lines changed

_conf/schemas.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,19 @@
111111
name=F(ref=True, required=True),
112112
attrs={
113113
'id': F(uniq=True, ref=True, required=True, indexers=[by_hyphen2]),
114-
'krs': F(form=F.Forms.LINES),
115-
'hrs': F(form=F.Forms.WORDS),
116-
'progs': F(form=F.Forms.WORDS),
117-
'scores': F(form=F.Forms.WORDS),
118114

119115
'kr1': F(form=F.Forms.LINES),
120116
'kr2': F(form=F.Forms.LINES),
121117
'kr3': F(form=F.Forms.LINES),
122118
'kr4': F(form=F.Forms.LINES),
123-
'done1': F(),
124-
'done2': F(),
125-
'done3': F(),
126-
'done4': F(),
127-
'score1': F(),
128-
'score2': F(),
129-
'score3': F(),
130-
'score4': F(),
119+
'kr5': F(form=F.Forms.LINES),
120+
'kr6': F(form=F.Forms.LINES),
131121

132122
'p0': F(ref=True),
133123
'p1': F(ref=True),
134124
'p2': F(ref=True),
125+
126+
'krs': F(form=F.Forms.LINES), # deprecated
135127
},
136128
description_template=open('_templates/okr.rst', 'r').read(),
137129
reference_template='🎯{{ title }}',

_templates/okr.rst

+29-38
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,42 @@
1-
:编号: :okr.id+by-path:`{{ id.split('-')[0] }} <{{ id }}>`\ ``-{{ id.split('-', maxsplit=1)[1]}}``
1+
:编号: :okr.id+by-path:`{{ id.split('-') | first }} <{{ id }}>`\ ``-{{ id.split('-', maxsplit=1) | first }}``
22
:优先级: {% if p0 is defined %}|p0|{% elif p1 is defined %}|p1|{% else %}|p2|{% endif %}
33
{% if id.count('-') == 2 %}:对齐: :okr:`{{ id.rsplit('-', maxsplit=1)[0] }}`{% endif %}
44
5+
{% if krs %}
6+
.. note:: 2025 前的 OKR 使用旧格式,已归档,请勿用此格式创建新 OKR
7+
.. code:: python
8+
9+
{{ krs }}
10+
11+
{% else %}
512
.. list-table::
613
:header-rows: 1
714
:align: center
815
:widths: auto
916
10-
* - Key Result
17+
* - KR
1118
- 进度
12-
- 分数
13-
14-
{# TODO: 2025-04-27: compat for old schema #}
15-
{% for n in range(krs | length) %}
16-
* - {{ krs[n] }}
17-
- {% if hrs and hrs | length > n and hrs[n] != '_' %} {{ hrs[n] }} 小时 {% else %} ⁿ̷ₐ {% endif %}
18-
- {% if progs and progs | length > n and progs[n] != '_' %} |{{ progs[n]}}| {% else %} ⁿ̷ₐ {% endif %}
19-
- {% if scores and scores | length > n and scores[n] != '_' %} |{{ scores[n] }}| {% else %} ⁿ̷ₐ {% endif %}
20-
{% endfor %}
2119
22-
{% if kr1 %}
23-
* - {% for line in kr1 %}
24-
{{ line }}
25-
{% endfor %}
26-
- {{ done1 or 'ⁿ̷ₐ' }}
27-
- {{ score1 or 'ⁿ̷ₐ' }}
28-
{% endif %}
29-
{% if kr2 %}
30-
* - {% for line in kr2 %}
31-
{{ line }}
32-
{% endfor %}
33-
- {{ done2 or 'ⁿ̷ₐ' }}
34-
- {{ score2 or 'ⁿ̷ₐ' }}
35-
{% endif %}
36-
{% if kr3 %}
37-
* - {% for line in kr3 %}
38-
{{ line }}
39-
{% endfor %}
40-
- {{ done3 or }}
41-
- {{ score3 or 'ⁿ̷ₐ' }}
42-
{% endif %}
43-
{% if kr4 %}
44-
* - {% for line in kr4 %}
45-
{{ line }}
20+
{% for i in range(1, 10) %}
21+
{% set kr = _['kr%d' % i] %}
22+
{%- if not kr %}{% continue %}{% endif %}
23+
{% set ns = namespace(progress = 'ⁿ̷ₐ', priority = 'p2') %}
24+
* - {% for line in kr %}
25+
{% if loop.first %}
26+
{% for v in line.split('|') %}
27+
{% if loop.last %}{% break%}{% endif %}
28+
{% if v.startswith('p') %}
29+
{% set ns.priority = v | trim %}
30+
{% elif '/' in v %}
31+
{% set ns.progress = v | trim %}
32+
{% endif %}
33+
{% endfor %}
34+
{% set line = line.split('|') | last %}
35+
{% endif %}
36+
|{{ ns.priority }}| {{ line | trim }}
4637
{% endfor %}
47-
- {{ done4 or 'ⁿ̷ₐ' }}
48-
- {{ score4 or 'ⁿ̷ₐ' }}
49-
{% endif %}
38+
- {{ ns.progress }}
39+
{% endfor %}
40+
{% endif %}
5041
5142
{{ content }}

notes/man/jinja2.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
======
2+
Jinja2
3+
======
4+
5+
`Live Jinja2 Parser <https://j2live.ttl255.com/>`_

0 commit comments

Comments
 (0)