@@ -99,7 +99,9 @@ class ConfigureCommand(Command):
9999
100100
101101class DocsPullCommand (ConfigureCommand ):
102- DESTINATION : Path = Path (__file__ ).parent .parent .joinpath ("content/docs" )
102+ DESTINATION = Path (__file__ ).parent .parent / "content" / "docs"
103+ HISTORY_DESTINATION = Path (__file__ ).parent .parent / "content" / "history.md"
104+ HISTORY_FRONTMATTER = "---\n type: page\n layout: single\n title: History\n ---\n \n "
103105 REPOSITORY = "https://github.com/python-poetry/poetry.git"
104106
105107 name = "docs pull"
@@ -120,12 +122,17 @@ class DocsPullCommand(ConfigureCommand):
120122
121123 self .DESTINATION .mkdir (parents = True )
122124
125+ if self .HISTORY_DESTINATION .exists ():
126+ self .HISTORY_DESTINATION .unlink ()
127+
123128 if self .option ("local" ):
129+ local_src = Path (self .option ("local" ))
124130 self ._pull_local_version (
125- src = Path ( self . option ( "local" )) ,
131+ src = local_src ,
126132 dest = self .DESTINATION ,
127133 editable = self .option ("editable" ),
128134 )
135+ self ._write_history (local_src / "CHANGELOG.md" )
129136 return 0
130137
131138 for name , version in versions .items ():
@@ -210,9 +217,24 @@ class DocsPullCommand(ConfigureCommand):
210217
211218 with path .joinpath (filepath .name ).open ("w" ) as f :
212219 f .write (new_content )
220+
221+ if version == "main" :
222+ self ._write_history (tmp_dir / "CHANGELOG.md" )
213223 finally :
214224 os .chdir (cwd .as_posix ())
215225
226+ def _write_history (self , changelog : Path ) -> None :
227+ if not changelog .exists ():
228+ raise RuntimeError (f"Changelog file not found at { changelog } " )
229+ self .line (f" Writing history from <b>{ changelog .name } </b>" )
230+ lines = changelog .read_text (encoding = "utf-8" ).splitlines (keepends = True )
231+ # replace changelog heading with history page title
232+ if lines and lines [0 ].lstrip ().startswith ("# " ):
233+ lines = lines [1 :]
234+ while lines and lines [0 ].strip () == "" :
235+ lines = lines [1 :]
236+ self .HISTORY_DESTINATION .write_text (self .HISTORY_FRONTMATTER + "" .join (lines ))
237+
216238
217239class BuildCommand (DocsPullCommand ):
218240 name = "build"
0 commit comments