@@ -83,10 +83,10 @@ def latex(self):
83
83
84
84
@reify
85
85
def css (self ):
86
- """ Returns lesson-specific extra CSS.
86
+ """Return lesson-specific extra CSS.
87
87
88
- If the lesson defines extra css , the scope of the styles is limited to ``.lesson-content``,
89
- a div which contains the actual lesson content.
88
+ If the lesson defines extra CSS , the scope of the styles is limited
89
+ to ``.lesson-content``, which contains the actual lesson content.
90
90
"""
91
91
css = self .info .get ("css" )
92
92
@@ -200,7 +200,7 @@ def convert_url(url):
200
200
201
201
@staticmethod
202
202
def limit_css_to_lesson_content (css ):
203
- """ Returns ``css`` limited just to the ``.lesson-content`` element.
203
+ """Return ``css`` limited just to the ``.lesson-content`` element.
204
204
205
205
This doesn't protect against malicious input.
206
206
"""
@@ -468,7 +468,7 @@ def _get_sessions(course, plan):
468
468
469
469
470
470
class CourseMixin :
471
- """ Couple of methods common for both :class:`Course` and :class:`CourseLink`.
471
+ """Methods common for both :class:`Course` and :class:`CourseLink`.
472
472
"""
473
473
474
474
@reify
@@ -506,10 +506,13 @@ def __str__(self):
506
506
507
507
data_filename = "info.yml" # for MultipleModelDirProperty
508
508
509
- # These two class attributes define what the function ``naucse.utils.forks:course_info`` returns from forks,
510
- # meaning, the function in the fork looks at these lists that are in the fork and returns those.
511
- # If you're adding an attribute to these lists, you have to make sure that you provide a default in
512
- # the CourseLink attribute since the forks already forked will not be returning the value.
509
+ # These two class attributes define what the function
510
+ # ``naucse.utils.forks:course_info`` returns from forks,
511
+ # meaning, the function in the fork looks at these lists
512
+ # that are in the fork and returns those.
513
+ # If you're adding an attribute to these lists, you have to
514
+ # make sure that you provide a default in the CourseLink
515
+ # attribute since existing forks don't contain the value.
513
516
COURSE_INFO = ["title" , "description" , "vars" , "canonical" ]
514
517
RUN_INFO = ["title" , "description" , "start_date" , "end_date" , "canonical" , "subtitle" , "derives" , "vars" ,
515
518
"default_start_time" , "default_end_time" ]
@@ -583,7 +586,7 @@ def optional_convert_time(timestr):
583
586
584
587
585
588
class CourseLink (CourseMixin , Model ):
586
- """ A link to a course from a separate git repo.
589
+ """A link to a course from a separate git repo.
587
590
"""
588
591
589
592
link = YamlProperty ()
@@ -619,7 +622,9 @@ def base_course(self):
619
622
return None
620
623
621
624
def render (self , page_type , * args , ** kwargs ):
622
- """ Renders a page in the fork, checks the content and registers urls to freeze.
625
+ """Render a page in the fork.
626
+
627
+ Check the content and registers URLs to freeze.
623
628
"""
624
629
naucse .utils .views .forks_raise_if_disabled ()
625
630
@@ -635,7 +640,8 @@ def render(self, page_type, *args, **kwargs):
635
640
allowed_elements_parser .reset_and_feed (result .output ["content" ])
636
641
637
642
if "urls" in result .output :
638
- # freeze urls generated by the code in fork, but only if they start with the slug of the course
643
+ # Freeze URLs generated by the code in fork, but only if
644
+ # they start with the slug of the course
639
645
absolute_urls_to_freeze .extend ([url for url in result .output ["urls" ] if url .startswith (f"/{ self .slug } /" )])
640
646
641
647
return result .output
@@ -662,12 +668,14 @@ def lesson_static(self, lesson_slug, path):
662
668
return filename .parent , filename .name
663
669
664
670
def get_footer_links (self , lesson_slug , page , ** kwargs ):
665
- """ Returns links to previous page, to current session and to the next page. Each link
666
- is either a dict with url and title keys or ``None``.
671
+ """Return links to previous page, current session and the next page.
672
+
673
+ Each link is either a dict with 'url' and 'title' keys or ``None``.
667
674
668
- If :meth:`render_page` fails and a canonical versions is in the base repo, it's used instead
669
- with a warning. This method provides the correct footer links for the page, since ``sessions``
670
- is not included in the info provided by forks.
675
+ If :meth:`render_page` fails and a canonical version is in the
676
+ base repo, it's used instead with a warning.
677
+ This method provides the correct footer links for the page,
678
+ since ``sessions`` is not included in the info provided by forks.
671
679
"""
672
680
naucse .utils .views .forks_raise_if_disabled ()
673
681
@@ -728,7 +736,8 @@ def __str__(self):
728
736
729
737
730
738
class MetaInfo :
731
- """ Info about the current repository. """
739
+ """Info about the current repository.
740
+ """
732
741
733
742
def __str__ (self ):
734
743
return "Meta Information"
@@ -738,8 +747,10 @@ def __str__(self):
738
747
739
748
@reify
740
749
def slug (self ):
741
- """ Returns the slug of the repository based on the current branch. Returns the default if not on a branch,
742
- the branch doesn't have a remote or the remote url can't be parsed.
750
+ """Return the slug of the repository based on the current branch.
751
+
752
+ Returns the default if not on a branch, the branch doesn't
753
+ have a remote, or the remote url can't be parsed.
743
754
"""
744
755
from naucse .views import logger
745
756
@@ -780,7 +791,7 @@ def slug(self):
780
791
781
792
@reify
782
793
def branch (self ):
783
- """ Returns the active branch name or master if not on a branch.
794
+ """Return the active branch name, or ' master' if not on a branch.
784
795
"""
785
796
from naucse .views import logger
786
797
@@ -831,9 +842,10 @@ def meta(self):
831
842
832
843
@reify
833
844
def safe_run_years (self ):
834
- # since even the basic info about the forked runs can be broken, we need to make sure the required info
835
- # is provided. If ``RAISE_FORK_ERRORS`` is set, exceptions are raised here, otherwise the run is
836
- # ignored completely.
845
+ # since even the basic info about the forked runs can be broken,
846
+ # we need to make sure the required info is provided.
847
+ # If ``RAISE_FORK_ERRORS`` is set, exceptions are raised here.
848
+ # Otherwise the run is ignored completely.
837
849
safe_years = {}
838
850
for year , run_years in self .run_years .items ():
839
851
safe_run_years = []
0 commit comments