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 descriptions to all the plugin category pages. #552

Merged

Conversation

andynu
Copy link
Contributor

@andynu andynu commented Nov 29, 2022

Edited: All the plugin category pages to add plugin descriptions

This uses descriptions extracted from the plugin pages themselves. This was @claremacrae's excellent idea since it retains any descriptions for plugins that are no longer present in the json feed.

This is intended as a one-time manual content adjustment. It was scripted to produce, but these areas of the category pages appear to be manually curated by humans, not machine generated, so I hesitate to introduce anything that manipulates them. Because of that the code that generates this is very strict and only manipulates lines that appear to be exactly a link to the target plugin page. There are a few examples where descriptions are not present or where the link line has been edited -- these lines have all been left exactly as they were. For example in the discontinued plugins page

- [[obsidian-extra-md-commands|Extra Markdown Commands]] (use [[obsidian-smarter-md-hotkeys|Smarter Markdown Hotkeys]] instead.)

Additionally this PR does not add descriptions to the uncategorized plugins page, as that has been automated in the related PR #551

This is another step in the overall progression of encouraging descriptions on all the plugin pages as described in #343

Code

Please forgive that this is not in python. As a throw-away one-time script I did it in the language that I know best. If we end up pursuing some ongoing automation, of course it will be in python. This script is meant to run in the root of the repository.

#!/usr/bin/env ruby

descriptions_hash = {} # key: page_name, value: description
Dir["02 - Community Expansions/02.05 All Community Expansions/Plugins/*.md"].map do |plugin_page_path|
  contents = File.read(plugin_page_path)
  if contents =~ /Mobile compatible: .*\n\n(.*)\n\n%% -----/
    descriptions_hash[File.basename(plugin_page_path, '.md')] = $1&.strip
  end
end

Dir["02 - Community Expansions/02.01 Plugins by Category/*.md"].each do |category_page_path|
  contents = File.readlines(category_page_path)
  in_list = false
  out_list = false
  new_contents = contents.map do |line|
    out_list = true if in_list && line =~ /^## /
    in_list = true if line =~ /^## Plugins in this category/

    if in_list && !out_list
      if line =~ /^- \[\[(.*?)(?:\|(.*)){0,1}\]\]\s*\n$/
        page_name, link_alias = $1, $2
        p page_name: page_name, link_alias: link_alias, line: line
        description = descriptions_hash[page_name]
        if !description.nil?
          "- [[#{page_name}|#{link_alias}]]: #{description}\n"
        else
          line # no description, leave it alone.
        end
      else
        line # leave the line alone.
      end
    else
      line
    end
  end

  File.write(category_page_path, new_contents.join)
end

Copy link
Contributor

@claremacrae claremacrae left a comment

Choose a reason for hiding this comment

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

Wow - awesome stuff.

I've reviewed all the changed files in both Obsidian and PyCharm diff view.

I made a very few comments about outliers.

I've approved the change, as I'm very happy to accept this as it is.

But will wait for you to comment on the comments, to say if you do feel like fixing anything by hand. Totally up to you...

- [[obsidian-youglish-plugin|Youglish Plugin]]: Use YouTube to improve your pronunciation. YouGlish gives you fast, unbiased answers about how words is spoken by real people and in context.
- [[flashcards-obsidian|Flashcards]]: Anki integration
- [[obsidian-to-anki-plugin|Obsidian_to_Anki]]: This is an Anki integration plugin! Designed for efficient bulk exporting.
- [[obsidian-apple-reminders-plugin|Apple Reminders]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine. Another one where there was no description in the linked plugin note.

@claremacrae
Copy link
Contributor

Hi @andynu - all your PR descriptions have been super clear, but this one is outstanding. Thank you ever so much for capturing the code you used to do the transformation.

@claremacrae
Copy link
Contributor

Closing and re-opening, to trigger GitHub Actions.

@claremacrae
Copy link
Contributor

It's bleating about conflicts in Uncategorized plugins.md - I think I can resolve conflicts by telling it to discord the changes made in the 3rd commit...

This uses descriptions extracted from the plugin pages themselves. This
was @claremacrae's excellent idea since it retains any descriptions for
plugins that are no longer present in the json feed.
@andynu andynu force-pushed the add-descriptions-to-category-pages branch from a668e3b to b12fbc2 Compare November 29, 2022 22:43
@claremacrae
Copy link
Contributor

Thank you. I'm feeling bad about pointing out those 2 trivial lines now, for the time it cost you. Sorry!

Are you OK for me to merge this now?

@andynu
Copy link
Contributor Author

andynu commented Nov 29, 2022

@claremacrae I just squashed all those changes.

@claremacrae
Copy link
Contributor

@claremacrae I just squashed all those changes.

Excellent idea.

@andynu
Copy link
Contributor Author

andynu commented Nov 29, 2022 via email

@claremacrae claremacrae merged commit f240696 into obsidian-community:main Nov 29, 2022
@andynu andynu deleted the add-descriptions-to-category-pages branch November 30, 2022 14:46
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