From 634c7f1ad0bc7636ebdd567d03a331c7ff3817e8 Mon Sep 17 00:00:00 2001 From: httpjamesm Date: Sat, 9 Mar 2024 10:52:57 -0500 Subject: [PATCH] docs: comments --- src/routes/question.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/routes/question.go b/src/routes/question.go index ff91131..e797d60 100644 --- a/src/routes/question.go +++ b/src/routes/question.go @@ -123,6 +123,7 @@ type viewQuestionInputs struct { Sub string } +// parseAndValidateParameters consolidates the URL and query parameters into an easily-accessible struct. func parseAndValidateParameters(c *gin.Context) (inputs viewQuestionInputs, err error) { questionId := c.Param("id") @@ -156,6 +157,7 @@ func parseAndValidateParameters(c *gin.Context) (inputs viewQuestionInputs, err return } +// fetchQuestionData sends the request to StackOverflow. func fetchQuestionData(soLink string) (resp *resty.Response, err error) { client := resty.New() resp, err = client.R().Get(soLink) @@ -261,15 +263,14 @@ func extractAnswersData(doc *goquery.Document, domain string) ([]types.FilteredA // processAnswerBody highlights syntax and processes code blocks within an answer's body. func processAnswerBody(bodyHTML string, domain string) string { - // Example placeholder function to process and highlight syntax in code blocks. - // You would replace this with your actual logic for syntax highlighting. highlightedBody := utils.HighlightSyntaxViaContent(bodyHTML) return highlightedBody } // extractAnswerAuthorInfo extracts the author name, URL, and timestamp from an answer block. +// It directly mutates the answer. func extractAnswerAuthorInfo(selection *goquery.Selection, answer *types.FilteredAnswer, domain string) { - authorDetails := selection.Find("div.post-signature").Last() // Assuming the last post signature contains the author info. + authorDetails := selection.Find("div.post-signature").Last() authorName := html.EscapeString(authorDetails.Find("div.user-details a").First().Text()) authorURL := "https://" + domain + authorDetails.Find("div.user-details a").AttrOr("href", "")