Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docstrings #309

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open

Conversation

lordlabuckdas
Copy link
Contributor

No description provided.

"""Base class for all core functions of the cloner

:param root: Website root URL
:type root: str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need type if the type annotated in function definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Sphinx mandates it and the type disappears from the parameter description in docs when we remove its :type from the docstring.

self.logger = logging.getLogger(__name__)
self.meta = {}

def convert(self, path):
def convert(self, path: str) -> None:
"""Convert all pages to a Snare-friendly form and write meta info
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is Snare-friendly format? :)

Copy link
Contributor Author

@lordlabuckdas lordlabuckdas Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to convey the renaming of files to their hashes but I now realize it sounds very vague. I have clarified it in 58eafef.

snare/cloner.py Outdated
@@ -111,7 +151,16 @@ async def process_link(self, url, level, check_host=False):
self.logger.error("ValueError while processing the %s link", url)
return res

async def replace_links(self, data, level):
async def replace_links(self, data: Union[bytes, str], level: int) -> BeautifulSoup:
"""Replace website links to make them suitable for serving
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does it mean "suitable"? try to be more concrete, maybe even with example

Copy link
Contributor Author

@lordlabuckdas lordlabuckdas Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have clarified it in 58eafef. Will add detailed descriptions to this and other functions in the next series of commits.



class HeadlessCloner(BaseCloner):
async def fetch_data(self, browser, current_url, level, try_count):
async def fetch_data(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding the docstring for the class as well

@lordlabuckdas lordlabuckdas marked this pull request as ready for review October 13, 2021 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants