Skip to content

Add 'Available since' to module API function docs#10229

Merged
oranagra merged 5 commits intoredis:unstablefrom
zuiderkwast:module-api-since
Feb 3, 2022
Merged

Add 'Available since' to module API function docs#10229
oranagra merged 5 commits intoredis:unstablefrom
zuiderkwast:module-api-since

Conversation

@zuiderkwast
Copy link
Contributor

@zuiderkwast zuiderkwast commented Feb 2, 2022

The script which generates the markdown docs from module.c is updated to include the version in which each module API function was introduced.

The script uses git tags to find this information. If git is not available or if we're not in a git repo, the 'since' is silently skipped.

The line **Available since:** (version) is added after the function prototype. Example markdown:

 <span id="RedisModule_Alloc"></span>
 
 ### `RedisModule_Alloc`
 
     void *RedisModule_Alloc(size_t bytes);
 
+**Available since:** 4.0.0
+
 Use like `malloc()`. Memory allocated with this function is reported in
 Redis INFO memory, used for keys eviction according to maxmemory settings
 and in general is taken into account as memory allocated by Redis.
 You should avoid using `malloc()`.
 

Rename to utils/generate-module-api-doc.rb

Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

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

impressive.
when i try it i get:

oran@Oran-laptop:~/work/redis$ ruby src/modules/gendoc.rb > ../redis-doc/topics/modules-api-ref.md 
fatal: Not a valid object name 4.0.0:src/modules/../module.c
fatal: Not a valid object name 4.0.1:src/modules/../module.c

i supposed that maybe it's because the script care where it was executed? but i tried running it from src or src/modules folders and got the same.
p.s. maybe it's time to move this file to the utils folder?

@zuiderkwast
Copy link
Contributor Author

zuiderkwast commented Feb 3, 2022

Apparently it does care where it's executed. I thought I had taken that into account :-/ and as you can see src/modules/../module.c is the actual path of module.c, but when this is passed to git, it get's confused. The path within git needs to be src/module.c simply.

@zuiderkwast
Copy link
Contributor Author

p.s. maybe it's time to move this file to the utils folder?

Sure, but doesn't that break some workflow? The diff is also harder to review if the file is moved and changed at the same time.

@oranagra
Copy link
Member

oranagra commented Feb 3, 2022

IIRC git handles renames great as long as not many lines are changed in the file.
i'm not aware of any workflow or script that uses this file

@oranagra
Copy link
Member

oranagra commented Feb 3, 2022

maybe rename to generate-module-api-doc.rb (add the word "module")?

@oranagra oranagra merged commit f4ecc79 into redis:unstable Feb 3, 2022
@zuiderkwast zuiderkwast deleted the module-api-since branch February 3, 2022 08:29
@oranagra
Copy link
Member

oranagra commented Feb 7, 2022

updating redis-doc: redis/redis-doc#1781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants