Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lesson Template
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
prace-lessons
Lesson Template
Commits
d77e664c
Commit
d77e664c
authored
9 years ago
by
Raniere Silva
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'swc/gh-pages' into gh-pages
parents
d3c7a910
816817bf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/check.py
+29
-16
29 additions, 16 deletions
tools/check.py
tools/filters/blockquote2div.py
+11
-1
11 additions, 1 deletion
tools/filters/blockquote2div.py
with
40 additions
and
17 deletions
tools/check.py
+
29
−
16
View file @
d77e664c
...
@@ -13,6 +13,7 @@ Call at command line with flag -h to see options and usage instructions.
...
@@ -13,6 +13,7 @@ Call at command line with flag -h to see options and usage instructions.
import
argparse
import
argparse
import
collections
import
collections
import
functools
import
glob
import
glob
import
hashlib
import
hashlib
import
logging
import
logging
...
@@ -25,6 +26,19 @@ import yaml
...
@@ -25,6 +26,19 @@ import yaml
import
validation_helpers
as
vh
import
validation_helpers
as
vh
NUMBER_OF_ERRORS
=
0
def
incr_error
(
func
):
"""
Wrapper to count the number of errors
"""
@functools.wraps
(
func
)
def
wrapper
(
*
args
,
**
kwargs
):
global
NUMBER_OF_ERRORS
NUMBER_OF_ERRORS
+=
1
return
func
(
*
args
,
**
kwargs
)
return
wrapper
logging
.
error
=
incr_error
(
logging
.
error
)
class
MarkdownValidator
(
object
):
class
MarkdownValidator
(
object
):
"""
Base class for Markdown validation
"""
Base class for Markdown validation
...
@@ -37,7 +51,7 @@ class MarkdownValidator(object):
...
@@ -37,7 +51,7 @@ class MarkdownValidator(object):
# Dict of tuples for each callout type: {style: (title, min, max)}
# Dict of tuples for each callout type: {style: (title, min, max)}
CALLOUTS
=
{}
CALLOUTS
=
{}
WARN_ON_EXTRA_HEADINGS
=
Tru
e
# Warn when other headings are present?
WARN_ON_EXTRA_HEADINGS
=
Fals
e
# Warn when other headings are present?
# Validate YAML doc headers: dict of {header text: validation_func}
# Validate YAML doc headers: dict of {header text: validation_func}
DOC_HEADERS
=
{}
DOC_HEADERS
=
{}
...
@@ -456,7 +470,8 @@ class IndexPageValidator(MarkdownValidator):
...
@@ -456,7 +470,8 @@ class IndexPageValidator(MarkdownValidator):
DOC_HEADERS
=
{
'
layout
'
:
vh
.
is_str
,
DOC_HEADERS
=
{
'
layout
'
:
vh
.
is_str
,
'
title
'
:
vh
.
is_str
}
'
title
'
:
vh
.
is_str
}
CALLOUTS
=
{
'
prereq
'
:
(
"
Prerequisites
"
,
1
,
1
)}
CALLOUTS
=
{
'
prereq
'
:
(
"
Prerequisites
"
,
1
,
1
),
'
getready
'
:
(
"
Getting ready
"
,
1
,
1
)}
def
_partition_links
(
self
):
def
_partition_links
(
self
):
"""
Check the text of every link in index.md
"""
"""
Check the text of every link in index.md
"""
...
@@ -500,17 +515,16 @@ class TopicPageValidator(MarkdownValidator):
...
@@ -500,17 +515,16 @@ class TopicPageValidator(MarkdownValidator):
The top-level document has no headings indicating subtopics.
The top-level document has no headings indicating subtopics.
The only valid subheadings are nested in blockquote elements
"""
The only valid subheadings are nested in blockquote elements
"""
heading_nodes
=
self
.
ast
.
get_section_headings
()
heading_nodes
=
self
.
ast
.
get_section_headings
()
if
len
(
heading_nodes
)
==
0
:
if
len
(
heading_nodes
)
!=
0
:
return
True
# Individual heading msgs are logged by validate_section_heading_order
logging
.
warning
(
"
In {0}:
"
"
Sub-headings are often a sign
"
"
a lesson needs to be split into multiple topics.
"
"
Please make sure this subsection doesn
'
t belong
"
"
in a separate lesson.
"
.
format
(
self
.
filename
))
# Individual heading msgs are logged by validate_section_heading_order
return
True
logging
.
error
(
"
In {0}:
"
"
The topic page should not have sub-headings
"
"
outside of special blocks.
"
"
If a topic needs sub-headings,
"
"
it should be broken into multiple topics.
"
.
format
(
self
.
filename
))
return
False
def
_run_tests
(
self
):
def
_run_tests
(
self
):
parent_tests
=
super
(
TopicPageValidator
,
self
).
_run_tests
()
parent_tests
=
super
(
TopicPageValidator
,
self
).
_run_tests
()
...
@@ -822,12 +836,11 @@ def main(parsed_args_obj):
...
@@ -822,12 +836,11 @@ def main(parsed_args_obj):
if
all_valid
is
True
:
if
all_valid
is
True
:
logging
.
debug
(
"
All Markdown files successfully passed validation.
"
)
logging
.
debug
(
"
All Markdown files successfully passed validation.
"
)
sys
.
exit
(
0
)
else
:
else
:
logging
.
warning
(
logging
.
warning
(
"
Some
errors were encountered during validation.
"
"
{0}
errors were encountered during validation.
"
"
See log for details.
"
)
"
See log for details.
"
.
format
(
NUMBER_OF_ERRORS
)
)
sys
.
exit
(
1
)
sys
.
exit
(
NUMBER_OF_ERRORS
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
tools/filters/blockquote2div.py
+
11
−
1
View file @
d77e664c
...
@@ -52,6 +52,7 @@ SPECIAL_CLASSES = {
...
@@ -52,6 +52,7 @@ SPECIAL_CLASSES = {
"
callout
"
:
(
"
panel-info
"
,
"
glyphicon-pushpin
"
),
"
callout
"
:
(
"
panel-info
"
,
"
glyphicon-pushpin
"
),
"
challenge
"
:
(
"
panel-success
"
,
"
glyphicon-pencil
"
),
"
challenge
"
:
(
"
panel-success
"
,
"
glyphicon-pencil
"
),
"
prereq
"
:
(
"
panel-warning
"
,
"
glyphicon-education
"
),
"
prereq
"
:
(
"
panel-warning
"
,
"
glyphicon-education
"
),
"
getready
"
:
(
"
panel-warning
"
,
"
glyphicon-check
"
),
"
objectives
"
:
(
"
panel-warning
"
,
"
glyphicon-certificate
"
),
"
objectives
"
:
(
"
panel-warning
"
,
"
glyphicon-certificate
"
),
}
}
...
@@ -113,7 +114,16 @@ def blockquote2div(key, value, format, meta):
...
@@ -113,7 +114,16 @@ def blockquote2div(key, value, format, meta):
# a blockquote is just a list of blocks, so it can be
# a blockquote is just a list of blocks, so it can be
# passed directly to Div, which expects Div(attr, blocks)
# passed directly to Div, which expects Div(attr, blocks)
return
pf
.
Div
((
id
,
classes
,
kvs
),
[
panel_header
,
panel_body
])
if
classes
[
0
]
==
"
callout
"
:
return
[{
"
t
"
:
"
RawBlock
"
,
"
c
"
:
[
"
html
"
,
"
<aside class=
\"
{0}
\"
>
"
.
format
(
'
'
.
join
(
classes
))
]},
panel_header
,
panel_body
,
{
"
t
"
:
"
RawBlock
"
,
"
c
"
:
[
"
html
"
,
"
</aside>
"
]}]
else
:
return
[{
"
t
"
:
"
RawBlock
"
,
"
c
"
:
[
"
html
"
,
"
<section class=
\"
{0}
\"
>
"
.
format
(
'
'
.
join
(
classes
))
]},
panel_header
,
panel_body
,
{
"
t
"
:
"
RawBlock
"
,
"
c
"
:
[
"
html
"
,
"
</section>
"
]}]
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment