Skip to content

Commit

Permalink
refactor completed?
Browse files Browse the repository at this point in the history
namespace is so much cleaner.

added module level docstrings

docstrings for most functions added

all unit tests passed
  • Loading branch information
ofloveandhate committed Jul 15, 2024
1 parent d184106 commit 9b85ee9
Show file tree
Hide file tree
Showing 26 changed files with 958 additions and 642 deletions.
16 changes: 12 additions & 4 deletions docs/classes.rst → docs/canvas_objects.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Concrete Classes
-------------------
Concrete Classes for Canvas Objects
--------------------------------------



Expand All @@ -12,6 +12,14 @@ Concrete Classes
:members:
:undoc-members:

.. autoclass:: markdown2canvas.Image
:members:
:undoc-members:


.. autoclass:: markdown2canvas.Link
:members:
:undoc-members:


.. autoclass:: markdown2canvas.File
Expand All @@ -32,11 +40,11 @@ Concrete Classes
Base Classes
--------------

.. autoclass:: markdown2canvas.CanvasObject
.. autoclass:: markdown2canvas.canvas_objects.CanvasObject
:members:
:undoc-members:


.. autoclass:: markdown2canvas.Document
.. autoclass:: markdown2canvas.canvas_objects.Document
:members:
:undoc-members:
6 changes: 3 additions & 3 deletions docs/exceptions.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Exceptions
-------------

.. autoclass:: markdown2canvas.AlreadyExists
.. autoclass:: markdown2canvas.exception.AlreadyExists
:members:
:undoc-members:

.. autoclass:: markdown2canvas.SetupError
.. autoclass:: markdown2canvas.exception.SetupError
:members:
:undoc-members:

.. autoclass:: markdown2canvas.DoesntExist
.. autoclass:: markdown2canvas.exception.DoesntExist
:members:
:undoc-members:
29 changes: 28 additions & 1 deletion docs/free_functions.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
Free functions
------------------
=====================


Setup functions
-------------------

.. automodule:: markdown2canvas.setup_functions
:members:



Functions for interacting with a course on Canvas
---------------------------------------------------

.. automodule:: markdown2canvas.course_interaction_functions
:members:


Functions markdown2canvas uses to translate from markdown to Canvas-html
--------------------------------------------------------------------------

.. automodule:: markdown2canvas.translation_functions
:members:

.. autofunction:: markdown2canvas.canvas_objects.find_local_images

.. autofunction:: markdown2canvas.canvas_objects.find_local_files


2 changes: 1 addition & 1 deletion docs/markdown2canvas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Python libraries used: `canvasapi`
.. toctree::
:maxdepth: 2

classes
canvas_objects
exceptions
free_functions

Expand Down
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
canvasapi
Pygments
Pygments
markdown
65 changes: 32 additions & 33 deletions markdown2canvas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
import canvasapi
import os.path as path
import os
import requests
"""
`markdown2canvas`, a library for containerizing and publishing Canvas content.
Containerization of content is via filesystem folders with a `meta.json` file specifying type of content. Some content types like Assignment and Page use `source.md`, while others like File and Image are just a `meta.json` plus the files.
Publishing content is via the `.publish` member function for the canvas object, like
import logging
```
my_assignment.publish(course)
```
# logging.basicConfig(encoding='utf-8')
Documentation may be found at the GitHub pages for this library. Use it.
import datetime
today = datetime.datetime.today().strftime("%Y-%m-%d")
log_level=logging.DEBUG
A more complete example might be
log_dir = path.join(path.normpath(os.getcwd()), '_logs')
```
import markdown2canvas as mc
canvas_url = "https://uweau.instructure.com/" # 🎯 REPLACE WITH YOUR URL
if not path.exists(log_dir):
os.mkdir(log_dir)
# get the course.
course_id = 705022 # 🎯 REPLACE WITH YOUR NUMBER!!!!!!!!!!!!!!!!!
course = canvas.get_course(course_id)
log_filename = path.join(log_dir, f'markdown2canvas_{today}.log')
# make the API object. this is from the `canvasapi` library, NOT something in `markdown2canvas`.
canvas = mc.make_canvas_api_obj(url=canvas_url)
my_assignment = mc.Assignent('path_to_assignment")
log_encoding = 'utf-8'
# finally, publish
my_assignment.publish(course)
```
"""

root_logger = logging.getLogger()
root_logger.setLevel(log_level)
handler = logging.FileHandler(log_filename, 'a', log_encoding)
root_logger.addHandler(handler)
# the root-level file for `markdown2canvas`

logging.debug(f'starting logging at {datetime.datetime.now()}')
__version__ = '0.'
__author__ = 'silviana amethyst, Mckenzie West, Allison Beemer'


logging.debug(f'reducing logging level of `requests` to WARNING')
logging.getLogger('canvasapi.requester').setLevel(logging.WARNING)
logging.getLogger('requests').setLevel(logging.WARNING)
import markdown2canvas.logging

import markdown2canvas.exception

from markdown2canvas.setup_functions import *

import markdown2canvas.translation_functions


from markdown2canvas.exception import AlreadyExists, SetupError, DoesntExist


from markdown2canvas.free_functions import *

from markdown2canvas.course_interaction_functions import *

################## classes

from markdown2canvas.base_classes import CanvasObject, Document
from markdown2canvas.classes import Page, Assignment, Image, BareFile, Link, File



from markdown2canvas.canvas_objects import CanvasObject, Document, Page, Assignment, Image, File, BareFile, Link


import markdown2canvas.canvas2markdown

import markdown2canvas.tool

Expand Down
Loading

0 comments on commit 9b85ee9

Please sign in to comment.