Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
ccfb5c74
Kaydet (Commit)
ccfb5c74
authored
Haz 15, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Removed obsolete literals_to_xrefs.py script.
üst
bfb5b715
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
182 deletions
+0
-182
literals_to_xrefs.py
docs/_ext/literals_to_xrefs.py
+0
-174
writing-documentation.txt
docs/internals/contributing/writing-documentation.txt
+0
-8
No files found.
docs/_ext/literals_to_xrefs.py
deleted
100644 → 0
Dosyayı görüntüle @
bfb5b715
"""
Runs through a reST file looking for old-style literals, and helps replace them
with new-style references.
"""
import
re
import
shelve
import
sys
refre
=
re
.
compile
(
r'``([^`\s]+?)``'
)
ROLES
=
(
'attr'
,
'class'
,
"djadmin"
,
'data'
,
'exc'
,
'file'
,
'func'
,
'lookup'
,
'meth'
,
'mod'
,
"djadminopt"
,
"ref"
,
"setting"
,
"term"
,
"tfilter"
,
"ttag"
,
# special
"skip"
)
ALWAYS_SKIP
=
[
"NULL"
,
"True"
,
"False"
,
]
def
fixliterals
(
fname
):
with
open
(
fname
)
as
fp
:
data
=
fp
.
read
()
last
=
0
new
=
[]
storage
=
shelve
.
open
(
"/tmp/literals_to_xref.shelve"
)
lastvalues
=
storage
.
get
(
"lastvalues"
,
{})
for
m
in
refre
.
finditer
(
data
):
new
.
append
(
data
[
last
:
m
.
start
()])
last
=
m
.
end
()
line_start
=
data
.
rfind
(
"
\n
"
,
0
,
m
.
start
())
line_end
=
data
.
find
(
"
\n
"
,
m
.
end
())
prev_start
=
data
.
rfind
(
"
\n
"
,
0
,
line_start
)
next_end
=
data
.
find
(
"
\n
"
,
line_end
+
1
)
# Skip always-skip stuff
if
m
.
group
(
1
)
in
ALWAYS_SKIP
:
new
.
append
(
m
.
group
(
0
))
continue
# skip when the next line is a title
next_line
=
data
[
m
.
end
():
next_end
]
.
strip
()
if
next_line
[
0
]
in
"!-/:-@[-`{-~"
and
all
(
c
==
next_line
[
0
]
for
c
in
next_line
):
new
.
append
(
m
.
group
(
0
))
continue
sys
.
stdout
.
write
(
"
\n
"
+
"-"
*
80
+
"
\n
"
)
sys
.
stdout
.
write
(
data
[
prev_start
+
1
:
m
.
start
()])
sys
.
stdout
.
write
(
colorize
(
m
.
group
(
0
),
fg
=
"red"
))
sys
.
stdout
.
write
(
data
[
m
.
end
():
next_end
])
sys
.
stdout
.
write
(
"
\n\n
"
)
replace_type
=
None
while
replace_type
is
None
:
replace_type
=
raw_input
(
colorize
(
"Replace role: "
,
fg
=
"yellow"
)
)
.
strip
()
.
lower
()
if
replace_type
and
replace_type
not
in
ROLES
:
replace_type
=
None
if
replace_type
==
""
:
new
.
append
(
m
.
group
(
0
))
continue
if
replace_type
==
"skip"
:
new
.
append
(
m
.
group
(
0
))
ALWAYS_SKIP
.
append
(
m
.
group
(
1
))
continue
default
=
lastvalues
.
get
(
m
.
group
(
1
),
m
.
group
(
1
))
if
default
.
endswith
(
"()"
)
and
replace_type
in
(
"class"
,
"func"
,
"meth"
):
default
=
default
[:
-
2
]
replace_value
=
raw_input
(
colorize
(
"Text <target> ["
,
fg
=
"yellow"
)
+
default
+
colorize
(
"]: "
,
fg
=
"yellow"
)
)
.
strip
()
if
not
replace_value
:
replace_value
=
default
new
.
append
(
":
%
s:`
%
s`"
%
(
replace_type
,
replace_value
))
lastvalues
[
m
.
group
(
1
)]
=
replace_value
new
.
append
(
data
[
last
:])
with
open
(
fname
,
"w"
)
as
fp
:
fp
.
write
(
""
.
join
(
new
))
storage
[
"lastvalues"
]
=
lastvalues
storage
.
close
()
#
# The following is taken from django.utils.termcolors and is copied here to
# avoid the dependency.
#
def
colorize
(
text
=
''
,
opts
=
(),
**
kwargs
):
"""
Returns your text, enclosed in ANSI graphics codes.
Depends on the keyword arguments 'fg' and 'bg', and the contents of
the opts tuple/list.
Returns the RESET code if no parameters are given.
Valid colors:
'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
Valid options:
'bold'
'underscore'
'blink'
'reverse'
'conceal'
'noreset' - string will not be auto-terminated with the RESET code
Examples:
colorize('hello', fg='red', bg='blue', opts=('blink',))
colorize()
colorize('goodbye', opts=('underscore',))
print(colorize('first line', fg='red', opts=('noreset',)))
print('this should be red too')
print(colorize('and so should this'))
print('this should not be red')
"""
color_names
=
(
'black'
,
'red'
,
'green'
,
'yellow'
,
'blue'
,
'magenta'
,
'cyan'
,
'white'
)
foreground
=
{
color_names
[
x
]:
'3
%
s'
%
x
for
x
in
range
(
8
)}
background
=
{
color_names
[
x
]:
'4
%
s'
%
x
for
x
in
range
(
8
)}
RESET
=
'0'
opt_dict
=
{
'bold'
:
'1'
,
'underscore'
:
'4'
,
'blink'
:
'5'
,
'reverse'
:
'7'
,
'conceal'
:
'8'
}
text
=
str
(
text
)
code_list
=
[]
if
text
==
''
and
len
(
opts
)
==
1
and
opts
[
0
]
==
'reset'
:
return
'
\x1b
[
%
sm'
%
RESET
for
k
,
v
in
kwargs
.
iteritems
():
if
k
==
'fg'
:
code_list
.
append
(
foreground
[
v
])
elif
k
==
'bg'
:
code_list
.
append
(
background
[
v
])
for
o
in
opts
:
if
o
in
opt_dict
:
code_list
.
append
(
opt_dict
[
o
])
if
'noreset'
not
in
opts
:
text
=
text
+
'
\x1b
[
%
sm'
%
RESET
return
(
'
\x1b
[
%
sm'
%
';'
.
join
(
code_list
))
+
text
if
__name__
==
'__main__'
:
try
:
fixliterals
(
sys
.
argv
[
1
])
except
(
KeyboardInterrupt
,
SystemExit
):
print
(
''
)
docs/internals/contributing/writing-documentation.txt
Dosyayı görüntüle @
ccfb5c74
...
@@ -355,14 +355,6 @@ look better:
...
@@ -355,14 +355,6 @@ look better:
That is, use metadata instead of titles.
That is, use metadata instead of titles.
* Add more links -- nearly everything that's an inline code literal
right now can probably be turned into a xref.
See the ``literals_to_xrefs.py`` file in ``_ext`` -- it's a shell script
to help do this work.
This will probably be a continuing, never-ending project.
* Whenever possible, use links. So, use ``:setting:`ADMINS``` instead
* Whenever possible, use links. So, use ``:setting:`ADMINS``` instead
of ````ADMINS````.
of ````ADMINS````.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment